Curly braces are also used to explicitly define your variables if there could be any ambiguity: [uk.php.net...]
jatar_k
1:37 pm on Jun 30, 2009 (gmt 0)
the links are god reading, the answer< i think, is like this, concatenate between braces
${'selected' . $_GET['id']} = ' selected';
NomikOS
2:51 am on Jul 1, 2009 (gmt 0)
&&... yes. it is:
${'selected' . $_GET['id']} = ' selected';
you can not say it's trivial but very useful, right?
"thanks for your help {$colegas}" && for jatar_k --the bible.
bkeep
5:26 am on Jul 1, 2009 (gmt 0)
I use something similar for setting the column names as my variable name so when I add a new column to the db it is automatically added to the variables list with the column contents
>> you can not say it's trivial but very useful, right?
I use variable variables for anything I can but it doesn't come up very often. Mostly I use them for working with variable amounts of data either in variables or in arrays.
NomikOS
8:07 am on Jul 11, 2009 (gmt 0)
I used forget all about this construction, but no more. Thanks.
Another use:
for ($i = 1; $i <= 20; $i++) { $img = $listing->{'images'.$i}; if ($img) echo "Picture[$i] = '{$img}_lg.jpg';\n"; }