note 777 modified in echo by ronabop

From: Date: Mon, 11 Sep 2000 18:16:01 +0000
Subject: note 777 modified in echo by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-4704@lists.php.net to get a copy of this message
To echo an Array of Arrays: A two-dimensional array is one array nested inside of another array. I assigned the two-dimensional array using the following format: $ref = array( "10" => array(1,2), "11" => array(3,4), "12" => array("john", "fred") ); The array $ref contains the arrays $10, $11, $12 as the three elements. The nested arrays need to be named by sequential numbers because when called, one references their name, not their element number within the outer array $ref. In order to print these nested arrays, I used a double for loop and an echo statement. This is done in the following manner: for($i = 10; $i <= 12; $i++) { for($j = 0; $j <= 1; $j++) { echo $ref[$i][$j] . "\n"; } } This will print 1234johnfred to the screen. http://www.php.net/manual/function.echo.php

« previous php.notes (#4704) next »