note 90822 modified in function.array-search by danbrown

From: Date: Mon, 11 May 2009 19:57:35 +0000
Subject: note 90822 modified in function.array-search by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154474@lists.php.net to get a copy of this message
A simple recursive array_search function : <?php function recursive_array_search($needle,$haystack) { foreach($haystack as $key=>$value) { $current_key=$key; if($needle===$value OR (is_array($value) && recursive_array_search($needle,$value))) { return $current_key; } } return false; } ?> --was-- A simple recursive array_search function : <?php function recursive_array_search($needle,$haystack) { foreach($haystack as $key=>$value) { $current_key=$key; if($needle===$value OR (is_array($value) && recursive_array_search($needle,$value))) { return $current_key; } } return false; } http://php.net/manual/en/function.array-search.php

« previous php.notes (#154474) next »