Majid Sadr Majid Sadr - 1 year ago 75
PHP Question

PHP - Multidimensional arrays can`t be in double quotations

I know I can use an array value in double quotation. Like this:

<?php echo "my name is: $arr[name]"; ?>

But when I use Multidimensional array, I can`t see my result:

<?php echo "he is $twoDimArr[family][1]"; ?>

Here, the output is: he is Array[1]

What`s the reason?

And I know I can use my code like this:

<?php echo "he is ".$twoDimArr[family][1]; ?>

But I don't want this.

Answer Source

You should enclose more complicated structures in curly braces:

echo "he is {$twoDimArr['family'][1]}";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download