php - how to check if values exist inside a multidimensional array -


i have array this:

array ( [206] => array     (         [1] => array             (                 [formatid] => 1                 [format] => cd                 [formatseourl] => cd             )      )  [556] => array     (         [] => array             (                 [formatid] =>                  [format] =>                  [formatseourl] =>              )      )  [413] => array     (         [3] => array             (                 [formatid] => 3                 [format] => casete                 [formatseourl] => casete             )      ) ) 

...and specific key want values, before need validate if there values. code build dont know how validate if there values inside array... ive tried isset, empty, count, array_key_exists no success... know im close...

$key = 556;  //if there no formats in array, dont bother create ul if (?????????formats exist in $array[$key]) { ?>     <ul><?php        foreach ($array[$key] $value) { ?>          <li><?php echo $value['format']; ?></li><?php        } ?>     </ul><?php } ?> 

call function format_exists($array[$key]) dig value see if format isset.

function format_exists($values) {   if (!$values || !is_array($values)) return false;    $data = array_shift($values);   return $data && is_array($data) && isset($data["format"]); } 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -