note 111057 deleted from control-structures.foreach by googleguy
| From: | googleguy@php.net | Date: | Thu, 10 Jan 2013 10:44:03 +0000 |
| Subject: | note 111057 deleted from control-structures.foreach by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-192875@lists.php.net to get a copy of this message | ||
Note Submitter: joehorn at gmail dot com
----
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