hey there,
as part of my application, I build an array of arrays. So, what I have is this:

$mainArray = array();
$mainArray = $somearray;//as built with results from a query
$mainArray = $someOtherArray;//built same as above

//I want to iterate:

foreach($mainArray as $array)
{
   foreach($array as $dataArray)
   {
      echo $dataArray['0'];
   }
}

But that seems to not work for me. I tried print_r($dataArray); inside my second foreach loop, but that shows that $dataArray is not read as an array. Rather, print_r prints out ints.

Any idea what's going on?

Thanks in advance.

is $dataArray an array also?
if not just echo $dataArray; or if it is an array try echo $dataArray[0];

hey jstfsklh211,
I have it working right now. I do not know what I missed because I forgot what my code looked like when it was not working, but it is working now.

The above is only the general form of what I have now. So the above is correct, but what I had was not exactly what the above generalizes.

thank you though.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.