note 12029 modified in function.array.php by jmcastagnetto
| From: | jmcastagnetto@php.net | Date: | Mon, 19 Mar 2001 23:37:58 +0000 |
| Subject: | note 12029 modified in function.array.php by jmcastagnetto | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-12557@lists.php.net to get a copy of this message | ||
[Editor's note: Looks like you missed the manual section: "String Operators" in
Chapter 10, and more importantly the section "Arrays" in Chapter 6
Reading the manual can save you a lot of time and headache.]
It took me a while to figure this out. I was trying to access elements of a multidimensional array
whose elements where associative arrays
e.g. $heroes=array(
array( name=>"sally",age=>12),
array( name=>"donald",age=>5)
);
If you try to access for example element heroes[0][name] which is "sally", as:
print "I love superhero: $heroes[0][name]";
what you will actually get is:
I love superhero Array[name]
What you should do is concatenate the variable with the text and not include it in the double quotes
hoping that php will interpret it like it does with simple scalars:
<?php
print "I love superhero: ".$heroes[0][name] ;
?>
regards,
thalis
http://www.php.net/manual/function.array.php.php