note 16852 deleted from function.array-search by jimw

From: Date: Sat, 08 Dec 2001 21:05:06 +0000
Subject: note 16852 deleted from function.array-search by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22183@lists.php.net to get a copy of this message
If you want to search for a value only in one column of all entries in a multidimensional array, here's a function that will do that for you. It returns a one-dimensional array containing the numerical index of each entry matched. (apologies for the horrible formatting -- this comment system sucks) function array_search_column($needle, $haystack, $column) { $matches = array(); foreach($haystack as $foo) { if($foo[$column] == $needle) array_push($matches, $i); $i++; } return $matches; }

« previous php.notes (#22183) next »