note 97004 added to function.max

From: Date: Sat, 27 Mar 2010 11:28:42 +0000
Subject: note 97004 added to function.max
Groups: php.notes 
Request: Send a blank email to php-notes+get-167445@lists.php.net to get a copy of this message
This Is Good Example: For max to min <?php function max_key($array) { foreach ($array as $key => $val) { if ($val == max($array)) return $key; } } $array = array(10, 2, 5, 7, 4,15,32,8,41,25); $array_count=count($array); for($i=1;$i<=$array_count;$i++){ $max_val[$i]=max_key($array); $view=$array[$max_val[$i]]; unset($array[$max_val[$i]]); print $view."<br />"; // } /* OUTPUT 41 // Max 32 25 15 10 8 7 5 4 2 //Min */ ?> ---- Server IP: 69.147.83.197 Probable Submitter: 92.51.78.38 ---- Manual Page -- http://www.php.net/manual/en/function.max.php Edit -- https://master.php.net/note/edit/97004 Del: integrated -- https://master.php.net/note/delete/97004/integrated Del: useless -- https://master.php.net/note/delete/97004/useless Del: bad code -- https://master.php.net/note/delete/97004/bad+code Del: spam -- https://master.php.net/note/delete/97004/spam Del: non-english -- https://master.php.net/note/delete/97004/non-english Del: in docs -- https://master.php.net/note/delete/97004/in+docs Del: other reasons-- https://master.php.net/note/delete/97004 Reject -- https://master.php.net/note/reject/97004 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#167445) next »