note 36921 added to function.array-search
| From: | anbolb at boltblue dot com | Date: | Mon, 27 Oct 2003 12:55:32 +0000 |
| Subject: | note 36921 added to function.array-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-59374@lists.php.net to get a copy of this message | ||
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.
----
Manual Page -- http://www.php.net/manual/en/function.array-search.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+36921
Delete -- http://master.php.net/manage/user-notes.php?action=delete+36921&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+36921&report=yes
Search -- http://master.php.net/manage/user-notes.php