note 16852 added to function.array-search

From: Date: Thu, 15 Nov 2001 22:10:13 +0000
Subject: note 16852 added to function.array-search
Groups: php.notes 
Request: Send a blank email to php-notes+get-20887@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; } -- http://www.php.net/manual/en/function.array-search.php http://master.php.net/manage/user-notes.php?action=edit+16852 http://master.php.net/manage/user-notes.php?action=delete+16852 http://master.php.net/manage/user-notes.php?action=reject+16852

« previous php.notes (#20887) next »