note 104096 rejected from function.echo by thiago

From: Date: Mon, 23 May 2011 14:09:28 +0000
Subject: note 104096 rejected from function.echo by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-179956@lists.php.net to get a copy of this message
Note Submitter: nainale72 at hotmail dot com ---- /* Simple examples of Arrays for newbies like me */ /* one dimension array*/ <?php $numbers=array(1,2,3,4); for($i=0; $i<4; $i++) { echo $numbers[$i] . " - " . $numbers[$i] * 2; } ?> /* multidimensional array*/ <?php $numbers[3][4] = array(); for ($i=0; $i<4; $i++) { $numbers[0][$i] = $i + 1; // i + 1 $numbers[1][$i] = $numbers0][$i] * $numbers[0][$i]; // n * n $numbers[2][$i] = $numbers[0][$i] / 2; // n/2 } for($j=0; $j<3; $j++){ for ($i=0; $i<10; $i++){ echo $numbers[$j][$i] . " "; } } ?> /* associative array */ <?php $cars["Chevrolet"][0] = 25000; $cars["Aston Martin"][0] = 35000; $cars["Ferrari"][0] = 100000; foreach($car as $num => $value) { print "\$car[$num] => $value.\n"; } ?> /* multidimensional associative array */ <?php $cars["Chevrolet"][0] = 25000; $cars["Aston Martin"][0] = 35000; $cars["Ferrari"][0] = 100000; $cars["Chevrolet"][1] = 20; $cars["Aston Martin"][1] = 30; $cars["Ferrari"][1] = 50; foreach ($cars as $id1 => $array1) { foreach ($array1 as $id2 => $value) { printf('printf car [%s] [%s] = %d;<br>', $id1, $id2, $value); echo " echo car [". $id1. "] [". $id2 . "] = ". $value . "<br/>"; } } ?>

« previous php.notes (#179956) next »