JeditL Posted August 3, 2009 Share Posted August 3, 2009 Hello I got two-dimensional array that contains multiple arrays: $array[$i][$j]=array('first'=>$row['name'],'second'=>$row['address']); I'm using while($row=mysql_fetch_array($result)) to get data to the array. That works fine but after I try to loop the array using foreach I get only first letters. Here is my code: for($i=0;$i<$num;$i++) { for($j=0;$j<$rows;$j++) { foreach($array[$i][$j] as $row) { echo $row['name']; } } } Can I use foreach to loop the array so that I get whole strings and not just first letters? If not can I do it with some other method? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/168620-problem-at-using-foreach-to-loop-array/ Share on other sites More sharing options...
Andy-H Posted August 3, 2009 Share Posted August 3, 2009 for($i=0;$i<$num;$i++) { for($j=0;$j<$rows;$j++) { foreach($array[$i][$j] as $row) { echo $row['first']; // $row['second'] for address. } } } Link to comment https://forums.phpfreaks.com/topic/168620-problem-at-using-foreach-to-loop-array/#findComment-889488 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.