note 104096 added to function.echo
| From: | nainale72 at hotmail dot com | Date: | Sun, 22 May 2011 22:40:11 +0000 |
| Subject: | note 104096 added to function.echo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-179943@lists.php.net to get a copy of this message | ||
/* 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/>";
}
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 46.222.6.61
----
Manual Page -- http://www.php.net/manual/en/function.echo.php
Edit -- https://master.php.net/note/edit/104096
Del: integrated -- https://master.php.net/note/delete/104096/integrated
Del: useless -- https://master.php.net/note/delete/104096/useless
Del: bad code -- https://master.php.net/note/delete/104096/bad+code
Del: spam -- https://master.php.net/note/delete/104096/spam
Del: non-english -- https://master.php.net/note/delete/104096/non-english
Del: in docs -- https://master.php.net/note/delete/104096/in+docs
Del: other reasons-- https://master.php.net/note/delete/104096
Reject -- https://master.php.net/note/reject/104096
Search -- https://master.php.net/manage/user-notes.php