note 29436 modified in function.array-search by vrana

From: Date: Tue, 17 Aug 2004 14:49:11 +0000
Subject: note 29436 modified in function.array-search by vrana
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-79888@lists.php.net to get a copy of this message
If you wanna find a value in multidimensional array with array_search. You should do the following: Use For-Each, that it solves your Problem! Example: $map = array( array( Name=>'Jordan' ), array( Name=>'Oneal' ) ); <?php $search_value = "Jordan"; foreach ($map as $key => $row) { foreach($row as $cell) { if ($cell == $search_value) print $key; } } ?> --was-- If you wanna find a value in multidimensional array with array_search. You should do the following: Use For-Each, that it solves your Problem! Example: $map = array( array( Name=>'Jordan' ), array( Name=>'Oneal' ) ); $search_value = "Jordan"; foreach ($map as $key => $row) { foreach($row as $cell) { if ($cell == $search_value) print $key; } } http://php.net/manual/en/function.array-search.php

« previous php.notes (#79888) next »