[thelist] MySQL/PHP Associative Array Insert
nicky
nicky at deveha.com
Sat Feb 1 13:02:01 CST 2003
> <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>
It's even better to not use double quotes (because php will note
evaluate what is inside simple quote, usefull for very long string) like
this :
$str='here are some values of an associative array:'.$assocArr['one'].',
'.{$assocArr['foo']}.', '.{$assocArr['bar']}.'.';
--
[ nicky ] [ nicky at deveha.com ] [ icq : 19223680 ]
More information about the thelist
mailing list