tags:

views:

97

answers:

1

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 to 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;

}
+1  A: 

floor($size) will make $size of value 2.5 to 2 and 0.8 to 0. Why are you using floor anyway?

Amarghosh
what should I use?
SlaPtHiS
`$size` only :)
Carlos Lima
Why don't you just use $size like `'<a style="font-size: '. $size . 'em'`?
Amarghosh
Thanks I'm a step ahead of you :)
SlaPtHiS
**?** **?** **?**
Amarghosh
@Slapthis: it would be nice if you gave his answer an upvote as well as selecting it as the accepted answer:) +1 from me.
Carlos Lima