php - Loop children of multidimensional array -
what best way loop through multidimensional array return matching indexed child elements in php?
the array created dynamically not know count. every item have pair, if empty string.
sample array:
array(1) { ["gallery"]=> array(2) { ["img"]=> array(2) { [0]=> string(5) "first" [1]=> string(6) "second" } ["test"]=> array(2) { [0]=> string(3) "one" [1]=> string(3) "two" } } }
desired result:
you can try below code desired output
<?php $array = array('gallery' => array("img" => array("first", "second"), "test" => array("one", "two"))); //var_dump($array); foreach($array $arr) { for($i=0;$i<count($arr['img']);$i++) { echo $arr['img'][$i].' '.$arr['test'][$i].'<br />'; } } ?>
let me know further needed
Comments
Post a Comment