note 36921 deleted from function.array-search by didou
| From: | didou@php.net | Date: | Mon, 27 Oct 2003 13:21:55 +0000 |
| Subject: | note 36921 deleted from function.array-search by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-59375@lists.php.net to get a copy of this message | ||
Note Submitter: anbolb@boltblue.com
----
This is good for sorting database results - for example, if you need to know which column contains
the largest value:
$dimensions = mysql_fetch_assoc (mysql_query ("SELECT width, height FROM item WHERE
item_id=$item_id"));
$size = array_search (max ($dimensions), $dimensions);
If the 'width' column contains the highest value, then $size contains the string
'width'. Substitute the max function for whatever you need to get the column name
you're looking for.