Anyone can explain it why is it true
$a = Array('b' = > 'okokokok');
if ( isset( $a['b']['ok'] ) ) {
echo $a['b']['ok']; // Print 0
} else {
echo "else";
}
Anyone can explain it why is it true
$a = Array('b' = > 'okokokok');
if ( isset( $a['b']['ok'] ) ) {
echo $a['b']['ok']; // Print 0
} else {
echo "else";
}
First of all, it doesn't print '0', but lowercase 'o'. Try this:
$string = 'abc';
echo $string['omgwhysuchkeyworks'];
It will print 'a'. That is because it seems in PHP when you try any key (other than numeric) on string variable it will return the first character of the string. That's also why isset($a['b']['ok'])
returns true.
And it might be an issue of the PHP version. Perhaps on newer version it will work as intended (it will write 'else')