note 12029 added to function.array.php

From: Date: Mon, 19 Mar 2001 18:20:41 +0000
Subject: note 12029 added to function.array.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-12548@lists.php.net to get a copy of this message
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/en/function.array.php

« previous php.notes (#12548) next »