jmurch Posted September 4, 2008 Share Posted September 4, 2008 I have a multidimensional array with integer autoindexed rows. I've tried using for and while loops and can't get at all 3 columns of data?? What is the correct way to loop thru an array when there are multiple dimensions? [0] => Array ( [1GNDU03E01D134411] => 30e049b900fb8b557976aec2d28cf0d2 ) [1] => Array ( [1B3ES56C43D141358] => cdee6dac61bd7b1d7976aec2d28cf0d2 ) [2] => Array ( [2C4GP44R04R604590] => c111b2875a2055097976aec2d28cf0d2 ) [3] => Array ( [2G2WP522351172282] => 46a554463aac34ea7976aec2d28cf0d2 ) Quote Link to comment https://forums.phpfreaks.com/topic/122734-solved-extracting-rows-from-multidimensional-array/ Share on other sites More sharing options...
obsidian Posted September 4, 2008 Share Posted September 4, 2008 You need to use foreach: <?php foreach ($arr as $i => $row) { foreach ($row as $k => $v) { echo "Current path: {$i} -> {$k} -> {$v}<br />\n"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/122734-solved-extracting-rows-from-multidimensional-array/#findComment-633799 Share on other sites More sharing options...
jmurch Posted September 4, 2008 Author Share Posted September 4, 2008 Thanks very much that did it. foreach ($cr_array as $i => $row) { foreach ($row as $k => $v) { echo "Current path: {$i} -> {$k} -> {$v}<br />\n"; } } Quote Link to comment https://forums.phpfreaks.com/topic/122734-solved-extracting-rows-from-multidimensional-array/#findComment-633801 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.