[nycphp-talk] Weird Switch Behavior
Michael B Allen
ioplex at gmail.com
Tue Sep 9 22:31:07 EDT 2008
Can someone explain why the below switch matches the 0 element?
$ cat switch.php
<?php
$tmp = array(
'foo' => 1,
'bar' => 2,
'zap',
);
foreach ($tmp as $key => $val) {
switch ($key) {
case 'foo':
case 'bar':
echo "[$key][$val]\n";
break;
}
}
$ php -f switch.php
[foo][1]
[bar][2]
[0][zap]
--
Michael B Allen
PHP Active Directory SPNEGO SSO
http://www.ioplex.com/
More information about the talk
mailing list