jasonc Posted September 6, 2010 Share Posted September 6, 2010 I am able to get all elements but the 'i*' parts. How do I do this. $formarray = array( 'name' => array( 'i1'=> array('a'=>'a1', 'b'=>'b1', 'c'=>'c1', 'd'=>'d1', 'e'=>'e1', 'f'=>'f1', 'g'=>'g1'), 'i2'=> array('a'=>'a2', 'b'=>'b2', 'c'=>'c2', 'd'=>'d2', 'e'=>'e2', 'f'=>'f2', 'g'=>'g2'), 'i3'=> array('a'=>'a3', 'b'=>'b3', 'c'=>'c3', 'd'=>'d3', 'e'=>'e3', 'f'=>'f3', 'g'=>'g3'), 'i4'=> array('a'=>'a4', 'b'=>'b4', 'c'=>'c4', 'd'=>'d4', 'e'=>'e4', 'f'=>'f4', 'g'=>'g4'), ) ); foreach ($formarray as $newarray => $a) { ?><strong><?=$newarray;?></strong><br><? foreach ($a as $key => $k) { foreach ($k as $b) { ?>"<?=$b;?>", <? } ?><br><? } //end of second foreach ?><br><br><br><? } //end of first foreach ?> Link to comment https://forums.phpfreaks.com/topic/212675-how-to-get-all-elements-of-array/ Share on other sites More sharing options...
mraza Posted September 6, 2010 Share Posted September 6, 2010 not sure if u are looking for they i1,i2... here is way to get key value with $key <?php $formarray = array( 'name' => array( 'i1'=> array('a'=>'a1', 'b'=>'b1', 'c'=>'c1', 'd'=>'d1', 'e'=>'e1', 'f'=>'f1', 'g'=>'g1'), 'i2'=> array('a'=>'a2', 'b'=>'b2', 'c'=>'c2', 'd'=>'d2', 'e'=>'e2', 'f'=>'f2', 'g'=>'g2'), 'i3'=> array('a'=>'a3', 'b'=>'b3', 'c'=>'c3', 'd'=>'d3', 'e'=>'e3', 'f'=>'f3', 'g'=>'g3'), 'i4'=> array('a'=>'a4', 'b'=>'b4', 'c'=>'c4', 'd'=>'d4', 'e'=>'e4', 'f'=>'f4', 'g'=>'g4'), ) ); foreach ($formarray as $newarray => $a) { ?><strong><?=$newarray;?></strong><br><? foreach ($a as $key => $k) { ?>"<?=$key;?>", <? foreach ($k as $b) { ?>"<?=$b;?>", <? } ?><br><? } //end of second foreach ?><br><br><br><? } //end of first foreach ?> Link to comment https://forums.phpfreaks.com/topic/212675-how-to-get-all-elements-of-array/#findComment-1107869 Share on other sites More sharing options...
jasonc Posted September 6, 2010 Author Share Posted September 6, 2010 gosh that simple in the end. thank you Link to comment https://forums.phpfreaks.com/topic/212675-how-to-get-all-elements-of-array/#findComment-1107872 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.