note 98258 deleted from function.in-array by danbrown
| From: | danbrown@php.net | Date: | Fri, 04 Jun 2010 15:59:52 +0000 |
| Subject: | note 98258 deleted from function.in-array by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-169890@lists.php.net to get a copy of this message | ||
Note Submitter: sean at crazyhorsecoding dot com
----
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