PHP How do I properly check if an array is multi-dimensional - strange array behavior

Posted by niggles on Stack Overflow See other posts from Stack Overflow or by niggles
Published on 2010-05-13T07:26:34Z Indexed on 2010/05/13 7:34 UTC
Read the original article Hit count: 182

Filed under:
|

If I have this array:

$foo[0] = 'bar';
$foo[1] = 'bar bar';

echo $foo[0][1];

// result
a
// i.e the second letter of 'bar'

I want to check that $foo[0][1] is not set i.e if I had:

$foo[0][1] = 'bar';

it would evaluate to true, but in my original example of $foo[0] = 'bar' I would expect that:

isset($foo[0][1])

would return false;

What's the correct way to test that please.

© Stack Overflow or respective owner

Related posts about php

Related posts about multidimensional-array