note 50867 added to control-structures.foreach
| From: | FanFataL at FanFataL dot pL | Date: | Sat, 12 Mar 2005 10:56:21 +0000 |
| Subject: | note 50867 added to control-structures.foreach | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-86317@lists.php.net to get a copy of this message | ||
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
)
----
Manual Page -- http://www.php.net/manual/en/control-structures.foreach.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50867
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50867&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50867&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50867&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50867&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50867&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50867&report=yes
Search -- http://master.php.net/manage/user-notes.php