How to escape a period for php and mysql question?
Okay here is what I'm, trying to do I want to escape the period so I can add a .8em font and a 2.5em font into my code for example instead of a plain number font. I tried escaping the period three different ways in this script but I think I was doing it wrong.
Here is my font sizes in the script.
$min_size = 1; //change to .8
$max_size = 2; //change t开发者_JS百科o 2.5
And here is part of the script that displays the font size.
$tags = tag_info();
$minimum_count = min(array_values($tags));
$maximum_count = max(array_values($tags));
$spread = $maximum_count - $minimum_count;
if($spread == 0) {
$spread = 1;
}
$cloud_html = '';
$cloud_tags = array();
foreach ($tags as $tag => $count) {
$size = $min_size + ($count - $minimum_count)
* ($max_size - $min_size) / $spread;
$cloud_tags[] = '<a style="font-size: '. floor($size) . 'em'
. '" class="tag_cloud" href="http://www.example.com/tags/' . $tag .'/'
. '" title="\'' . $tag . '\' returned a count of ' . $count . '">'
. htmlspecialchars(stripslashes($tag)) . '</a>';
}
$cloud_html = join("\n", $cloud_tags) . "\n";
return $cloud_html;
}
floor($size)
will make $size
of value 2.5
to 2
and 0.8
to 0
. Why are you using floor
anyway?
精彩评论