Posted by David Gillen on 02/17/06 13:45
An noise sounding like Dave said:
> I'm a bit unclear on the variable variables section of the PHP manual.
> Here's what I want to accomplish:
>
> $01_varA="foo"
> $02_varA="bar"
> $03_varB="boo"
> $04_varB="far"
>
> "01" through "04" are being gathered via mysql query as "id" in the
> example.
>
>
> I want to do this.....
>
> $sql_query=("SELECT * from database");
>
> while ($sql_array=($sql_query)){
> echo $sql_array["id"] . "_varA";
> echo $sql_array["id"] . "_varB";
> }
>
> ...so that it will echo the values of $01_varA, $02_varA, $03_varB and
> $04_varB in no particular order.
>
Do
$varstr = $sql_array["id"] . "_varA";
echo $$varstr
And that will echo $01_varA
db
--
/(bb|[^b]{2})/
Trees with square roots don't have very natural logs.
What's the difference between ignorance and apathy? Who knows? Who cares?
[Back to original message]
|