[thelist] MySQL/PHP Associative Array Insert
gabriel rivera
evolt at protocol0.com
Sat Feb 1 20:43:07 CST 2003
You can even get away with not quoting the array keys at all. This is
arguably a Bad Thing.
$str = "Here are some values from the array. " ;
$str .= "$assocArr[one] $assocArr[two] $assocArr[etc] " ;
nicky wrote:
>> <tip type="php - cleaner code">
>>
>> If you are using complex variables such as associative arrays in a
>> string you can enclose them with curly braces in order to get PHP to
>> parse them.
>> ie:
>> $str = "here are some values of an associative array:
>> {$assocArr['one']}, {$assocArr['foo']}, {$assocArr['bar']}.";
>> much nicer (IMO) than
>> $str = "here are some values of an associative array:
>> ".$assocArr['one'].", ".{$assocArr['foo']}.", ".{$assocArr['bar']}.".";
>>
>> </tip>
More information about the thelist
mailing list