Am Samstag, 18. November 2006 22:08 schrieb Erik Gyepes:
> Oliver Block wrote:
> > Am Samstag, 18. November 2006 19:46 schrieb Erik Gyepes:
> >
> > What exactly do you need to do? You should read the manual too, at
>
> 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.
>>$navigationItemArr = array("Home"=>"home",
>> "Profile"=>"profile",
>> "Photogallery"=>"photogallery",
>> "Contact"=>array("contact","subsection")
>> );
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.nak-nrw.de/index.php?id=71>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php