note 103033 added to function.max

From: Date: Mon, 21 Mar 2011 23:46:47 +0000
Subject: note 103033 added to function.max
Groups: php.notes 
Request: Send a blank email to php-notes+get-178064@lists.php.net to get a copy of this message
You can use this code to return the key for the maximum value in an array. mick at wireframe dot com's solution works, he just forgot the 'current' keyword <?php $array = array(1, 2, 5, 7, 4); echo max($array); // 7 echo current(array_keys($array,max($array))); // 3 ?> ---- Server IP: 69.147.83.197 Probable Submitter: 71.130.10.143 ---- Manual Page -- http://www.php.net/manual/en/function.max.php Edit -- https://master.php.net/note/edit/103033 Del: integrated -- https://master.php.net/note/delete/103033/integrated Del: useless -- https://master.php.net/note/delete/103033/useless Del: bad code -- https://master.php.net/note/delete/103033/bad+code Del: spam -- https://master.php.net/note/delete/103033/spam Del: non-english -- https://master.php.net/note/delete/103033/non-english Del: in docs -- https://master.php.net/note/delete/103033/in+docs Del: other reasons-- https://master.php.net/note/delete/103033 Reject -- https://master.php.net/note/reject/103033 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#178064) next »