note 86017 added to function.max
| From: | MarcusZacco at osu1 dot php dot net | Date: | Mon, 29 Sep 2008 16:47:23 +0000 |
| Subject: | note 86017 added to function.max | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-144878@lists.php.net to get a copy of this message | ||
This code loops through seven arrays and finds the highest average value within those arrays - and
changes the font color for it. Great for highlighting.
The biggest take-away is this the row
if($average[$i] == max($average))
The number_format just rounds the numbers to 0 decimal points.
for ( $i = 0; $i <= 6; $i++) {
$num = $i+1;
if($average[$i] == max($average))
echo "Value ".$num.": <font
color='red'>".number_format($average[$i], 0, '.', '')." %
</font><br>";
else echo "Value ".$num.": ".number_format($average[$i], 0, '.',
'')." %<br>";
}
### OUTPUT
Value 1: 52 %
Value 2: 58 %
Value 3: 56 %
Value 4: 73 %
Value 5: 77 % <- this 77 is highlighted in red
Value 6: 71 %
Value 7: 75 %
----
Server IP: 69.147.83.197
Probable Submitter: 85.226.191.34
----
Manual Page -- http://www.php.net/manual/en/function.max.php
Edit -- https://master.php.net/note/edit/86017
Del: integrated -- https://master.php.net/note/delete/86017/integrated
Del: useless -- https://master.php.net/note/delete/86017/useless
Del: bad code -- https://master.php.net/note/delete/86017/bad+code
Del: spam -- https://master.php.net/note/delete/86017/spam
Del: non-english -- https://master.php.net/note/delete/86017/non-english
Del: in docs -- https://master.php.net/note/delete/86017/in+docs
Del: other reasons-- https://master.php.net/note/delete/86017
Reject -- https://master.php.net/note/reject/86017
Search -- https://master.php.net/manage/user-notes.php