Jump to content

Problem at using foreach to loop array


JeditL

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.