RE: Going loopy with arrays.....

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yeah, that foreach is outright printing the arrays (foreach $parent...  print $parent?)

I'm guessing you wouldn't ask this, Jay, unless there was an issue with not knowing the depth of the data.

I saw something once with doing recursive function calls to dig down into an array or something.  So it'd be something like this:

function finddata($arr) {
  foreach ($arr as $key => $value) {
    if (substr($key, 0, 1) == "H") {
      echo "<b><i>$key</i></b><br>\n";
      foreach ($value as $subkey => $subvalue) {
        echo "[$subkey] lat: " . $subvalue["lat"] . " long: " . $subvalue["lon"] . "<br>\n";
      }
    } else {
      finddata($value);
    }
  }
}

finddata($mainarray);



Something like that..  my brain's working at 50% today as it is, but maybe this gives you a nudge in the right direction.

-TG

= = = Original message = = =

[snip]
foreach ($parent as $child)

    print $parent;

    foreach ($child as $item) 
            print $child . "=" . $item;
    



didn't test it, but this should work.
[/snip]

Didn't work, returns ArrayArray=ArrayArrayArray=ArrayArray=Array


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux