Re: Going loopy with arrays.....
| From: | tg-php at gryffyndevelopment dot com | Date: | Fri, 31 Mar 2006 18:26:16 +0000 |
| Subject: | Re: Going loopy with arrays..... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-233008@lists.php.net to get a copy of this message | ||
Yeah.. or something like this! (Chris' looks better than mine.. maybe his brain's working
at 70% today :)
-TG
= = = Original message = = =
> a. loop through it and recognize when I have com upon a new sub-array so
> that I can do 'new' output
> 2. OR get each of the sub-arrays out as individual arrays.
This might help get you going in the right direction...
<script language="php">
function print_elements( $var )
if( is_array( $var ))
foreach( $var as $k => $v )
if( is_array( $v ))
print_elements( $v );
else
echo "$k => $v<br>";
$array = array();
$array['H7'][] = array( 'lon' => -99.2588, 'lat' => 29.1918 );
$array['H7'][] = array( 'lon' => -99.2205, 'lat' => 29.1487 );
$array['H7'][] = array( 'lon' => -99.242, 'lat' => 29.1575 );
$array['H7'][] = array( 'lon' => -99.2588, 'lat' => 29.1545 );
$array['H6'][] = array( 'lon' => -99.0876, 'lat' => 29.216 );
$array['H6'][] = array( 'lon' => -99.0618, 'lat' => 29.179 );
array_walk( $array, 'print_elements' );
</script>
thnx,
Chris
___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.