tgrk35
04-29-2007, 06:37 PM
Is there a way to use in_array() with 2d arrays?
Will I have to loop it or something?
Thanks :)
Will I have to loop it or something?
Thanks :)
|
Click to See Complete Forum and Search --> : in_array() with 2d arrays tgrk35 04-29-2007, 06:37 PM Is there a way to use in_array() with 2d arrays? Will I have to loop it or something? Thanks :) NogDog 04-29-2007, 09:06 PM You could use something like the following to search any array, regardless of number of dimensions. (Warning: untested.) function inMyArray($array, $search) { foreach($array as $value) { if(is_array($value)) { if(inMyArray($value, $search)) { return(TRUE); } } elseif($value == $search) { return(TRUE); } } return(FALSE); } webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |