|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-02-05 00:30 UTC] php dot net at chiefworks dot com
<?php
$var = array(
'name' => array(
'first' => 'Caleb',
'last' => 'Maclennan'
)
);
echo "My first name is $var[name][first]!";
?>
Acutal Result:
My first name is Array[first]!
Correct Result:
My first name is Caleb!
This get's really nasty when useing 3 dimentional arrays to put data in SQL querys. The above example can easily be done by takeing the variable out of the quotes and useing "." to add it to the end, but there are other cases where the only solution is to do like this:
<?php
$tempVar = $var[name][first];
echo "My name is $tempVar";
?>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Jan 22 22:00:01 2026 UTC |
This is not true. The following is perfectly valid: echo "My first name is {$var['name']['first']}!";