[PHP] How to check value in multidimensional array

[PHP] How to check value in multidimensional array

Post by php-develo » Mon, 20 Nov 2006 06:08:32



I would like to check if the value is really in the array, if it is not
then I would like do some other things. (so not check if it is an array
or not, as in your example) But my iteration not worked in
multidimensional arrays.
 
 
 

[PHP] How to check value in multidimensional array

Post by list » Mon, 20 Nov 2006 06:46:38

Am Samstag, 18. November 2006 22:08 schrieb Erik Gyepes:



foreach($navigationItemArr as $k => $v) {
if(is_array($v) {
/* $v is array */
foreach($v as $kk => $vv) {
/* $kk hold the keys, $vv the associated values */
}
} else {
/* $v is no array*/
}
}

If you have to handle deeper nesting, i.e. $vv can hold arrays too, you should
use a recursion. If only $v can hold an array and not $vv the above should
work.

Regards,

Oliver


--
Leben ist mehr als ...
< http://www.yqcomputer.com/ ;

 
 
 

[PHP] How to check value in multidimensional array

Post by cliv » Thu, 23 Nov 2006 22:48:16


http://www.yqcomputer.com/

and look at the first User Contributed Notes.