note 68424 added to function.array-search

From: Date: Wed, 26 Jul 2006 14:19:45 +0000
Subject: note 68424 added to function.array-search
Groups: php.notes 
Request: Send a blank email to php-notes+get-115219@lists.php.net to get a copy of this message
/** * Searches haystack for needle and returns an array of the key path if it is found in the (multidimensional) array, FALSE otherwise. * * mixed array_searchRecursive ( mixed needle, array haystack [, bool strict[, array path]] ) */ function array_searchRecursive( $needle, $haystack, $strict=false, $path=array() ) { if( !is_array($haystack) ) { return false; } foreach( $haystack as $key => $val ) { if( is_array($val) && $subPath = array_searchRecursive($needle, $val, $strict, $path) ) { $path = array_merge($path, array($key), $subPath); return $path; } elseif( (!$strict && $val == $needle) || ($strict && $val === $needle) ) { $path[] = $key; return $path; } } return false; } ---- Server IP: 217.160.72.57 Probable Submitter: 212.95.105.213 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.array-search.php Edit -- http://master.php.net/note/edit/68424 Del: integrated -- http://master.php.net/note/delete/68424/integrated Del: useless -- http://master.php.net/note/delete/68424/useless Del: bad code -- http://master.php.net/note/delete/68424/bad+code Del: spam -- http://master.php.net/note/delete/68424/spam Del: non-english -- http://master.php.net/note/delete/68424/non-english Del: in docs -- http://master.php.net/note/delete/68424/in+docs Del: other reasons-- http://master.php.net/note/delete/68424 Reject -- http://master.php.net/note/reject/68424 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#115219) next »