note 111057 added to control-structures.foreach
| From: | joehorn at gmail dot com | Date: | Thu, 10 Jan 2013 09:54:12 +0000 |
| Subject: | note 111057 added to control-structures.foreach | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-192874@lists.php.net to get a copy of this message | ||
Notice following code & (strange) result .
** Code **
<?php
$arr = array();
array_push( $arr , 1 );
array_push( $arr , 2 );
array_push( $arr , 3 );
$arr['a'] = 'A';
$arr['b'] = 'B';
$arr['c'] = 'C';
foreach ( $arr as $k => $v ) {
if ( $k == 'b' ) {
echo "$k => $v" . PHP_EOL;
}
if ( $k === 'b' ) {
echo "$k ==> $v" . PHP_EOL;
}
}
?>
** Result **
0 => 1
b => B
b ==> B
----
Server IP: 69.147.83.199
Probable Submitter: 220.133.5.87
----
Manual Page -- http://php.net/manual/en/control-structures.foreach.php
Edit -- https://master.php.net/note/edit/111057
Del: integrated -- https://master.php.net/note/delete/111057/integrated
Del: useless -- https://master.php.net/note/delete/111057/useless
Del: bad code -- https://master.php.net/note/delete/111057/bad+code
Del: spam -- https://master.php.net/note/delete/111057/spam
Del: non-english -- https://master.php.net/note/delete/111057/non-english
Del: in docs -- https://master.php.net/note/delete/111057/in+docs
Del: other reasons-- https://master.php.net/note/delete/111057
Reject -- https://master.php.net/note/reject/111057
Search -- https://master.php.net/manage/user-notes.php