Beispiel #1
0
$a4 = array("zero" => 10, "one" => 20, "two" => 30, "three" => 40, "four" => 50);
$a6 = array("2" => 30, "4" => 50, "0" => 10, "3" => 40, "1" => 20);
// Iterate using the foreach loop.  Note the orderings.
showa($a1);
showa($a2);
showa($a3);
showa($a4);
showa($a5);
showa($a6);
// Iterate using "traditional" for loop.  Note some missing values.
showb($a1);
showb($a2);
showb($a3);
showb($a4);
showb($a5);
showb($a6);
// The print_r function will print out all of the contents of a PHP
// array.
print_r($a1);
echo "<br/>\n";
print_r($a2);
echo "<br/>\n";
print_r($a3);
echo "<br/>\n";
print_r($a4);
echo "<br/>\n";
print_r($a5);
echo "<br/>\n";
echo "<br/>\n";
echo "<hr/>\n";
unset($a1);
Beispiel #2
0
// C++ programmers.  Be careful when using these types of keys
$a3 = array(9 => 10, 10 => 20, 11 => 30, 12 => 40, 13 => 50);
$a4 = array("zero" => 10, "one" => 20, "two" => 30, "three" => 40, "four" => 50);
$a5 = array("zero" => 10, 1 => 20, 2 => 30, "three" => 40, 4 => 50);
// Iterate using the foreach loop.  Note the orderings.
showa($a1);
showa($a2);
showa($a3);
showa($a4);
showa($a5);
// Iterate using "traditional" for loop.  Note some missing values.
showb($a1);
showb($a2);
showb($a3);
showb($a4);
showb($a5);
// The print_r function will print out all of the contents of a PHP
// array.
print_r($a1);
echo "<br/>\n";
print_r($a2);
echo "<br/>\n";
print_r($a3);
echo "<br/>\n";
print_r($a4);
echo "<br/>\n";
print_r($a5);
echo "<br/>\n";
echo "<br/>\n";
echo "<hr/>\n";
unset($a1);