How to check value in multidimensional array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi guys,

I have an array with navigation items like that:

$navigationItemArr = array("Home"=>"home",
                 "Profile"=>"profile",
                 "Photogallery"=>"photogallery",
                 "Contact"=>array("contact","subsection")
                 );

How can I check for a value in this array?
I tried something like this:


.
.
..for.... $i++.. { // there is a normal for cycle, this is just an illustration
.
.

       if(in_array($bodyVariablePiece[$i], $navigationItemArr)) {
           echo "$bodyVariablePiece[$i] [$i] - ok<br />";
       }
       else {
           echo "$bodyVariablePiece[$i] [$i] - error<br />";
       }
.
.
}
.
.


* in $bodyVariablePiece are values extracted from URL like - home, profile, photogallery, contact Everything works except contact - there it show error. So what is the correct way to check values in multidimensional arrays? Is it possible with in_array() function?

Thanks,
Erik

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux