Variable in a variable name
Posted: Sun Mar 05, 2006 6:39 am
Hi,
Does anyone know how to get a variable in a variable name?
Thanks,
Chris
Does anyone know how to get a variable in a variable name?
Thanks,
Chris
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
$One = 1;
$Two = 2;
$Data = array();
$Data[$One] = "Whatever";
$Data[$Two] = $Anything;
echo $Data[1]; // prints WhateverCode: Select all
$Resource = mysql_query("select `field1`, `field2` from `table`",$Link_ID);
$Counter = 0;
$Records = array();
while ($Data = mysql_fetch_assoc($Resource)) {
$Records[$Counter] = $Data;
$Counter++;
}
// then you can get it back out
echo $Records[0]['field1'];