RE: [PHP] Going loopy with arrays.....
| From: | tg-php at gryffyndevelopment dot com | Date: | Fri, 31 Mar 2006 18:11:10 +0000 |
| Subject: | RE: [PHP] Going loopy with arrays..... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-233004@lists.php.net to get a copy of this message | ||
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.