[snip]
But the var isn't empty.
$a[] = 'blah';
$a[] = 'blah';
$a['assoc'] = 'array';
foreach ($a as $k => $v)
if ($k == 'assoc')
# do something
The 'if' statement is incorrectly executing when $k is 0. I find it
strange
that 0 == any string. The way I see it, 0 is false. false == 'a
string'
should not be true.
[/snip]
I changed this sample to the following;
<?php
$a[] = 'blah';
$a[] = 'blah';
$a['assoc'] = 'array';
print_r($a);
foreach ($a as $k => $v){
if ($k == 'assoc'){
echo $v . "\n";
}
}
?>
Andf the output was;
Array
(
[0] => blah
[1] => blah
[assoc] => array
)
blah
array
Does it begin to make more sense now?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php