note 50867 deleted from control-structures.foreach by nlopess
| From: | nlopess@php.net | Date: | Mon, 14 Mar 2005 16:59:51 +0000 |
| Subject: | note 50867 deleted from control-structures.foreach by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-86430@lists.php.net to get a copy of this message | ||
Note Submitter: FanFataL at FanFataL dot pL
----
Note, if you are using foreach....
Let's see what happends when we are using foreach on different version of php.
<?php
$array=array(3=>'three',4=>'four',5=>'five');
foreach($array as $key=>$val) {
print_r($val);
echo "\r\n";
}
echo "---------------\r\n";
foreach($array as $val) {
print_r($val);
echo "\r\n";
}
?>
The result is ( php 4.3.9 and php 5.0.1 ): <-- I think this is correct
three
four
five
---------------
three
four
five
The result on php 4.3.10 is little diffrent and I don't know why:
three
four
five
---------------
Array
(
[0] => three
[1] => 3
)
Array
(
[0] => four
[1] => 4
)
Array
(
[0] => five
[1] => 5
)