note 98258 added to function.in-array
| From: | sean at crazyhorsecoding dot com | Date: | Fri, 04 Jun 2010 15:57:31 +0000 |
| Subject: | note 98258 added to function.in-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-169889@lists.php.net to get a copy of this message | ||
function findRowByKeyVal($arr,$key,$val) {
// search for a particular value in a particular column in and return the entire row
$index_val = -1;
$o = array();
foreach ($arr as $row) {
$index_val++;
if ($row[$key] == $val) {
$o = $arr[$index_val];
break;
}
}
return $o;
}
// example: $rrow = findRowByKeyVal($states,'abbreviation','CA');
// returns the california row from the $states array
----
Server IP: 216.235.13.26
Probable Submitter: 66.207.212.130
----
Manual Page -- http://www.php.net/manual/en/function.in-array.php
Edit -- https://master.php.net/note/edit/98258
Del: integrated -- https://master.php.net/note/delete/98258/integrated
Del: useless -- https://master.php.net/note/delete/98258/useless
Del: bad code -- https://master.php.net/note/delete/98258/bad+code
Del: spam -- https://master.php.net/note/delete/98258/spam
Del: non-english -- https://master.php.net/note/delete/98258/non-english
Del: in docs -- https://master.php.net/note/delete/98258/in+docs
Del: other reasons-- https://master.php.net/note/delete/98258
Reject -- https://master.php.net/note/reject/98258
Search -- https://master.php.net/manage/user-notes.php