|
Posted by jamen on 12/11/05 18:28
number1.email@gmail.com wrote:
> I'm passing into a .php file the following:
>
> I have an array called $q[], which has the contents:
>
> $q[0] = 2
> $q[1] = 4
> $q[2] = 5
> $q[3] = 3
>
> Also, there are variables:
> $quest1 = "First"
> $quest2 = "Second"
> $quest3 = "Third"
> $quest4 = "Fourth"
> $quest5 = "Fifth"
>
> I'd like to be able to loop through this array (ie: $q[]) via a for
> loop, and create the name of the other variables from the contents (ie:
> $quest4 by concatenating "$quest" + $q[1] , $quest5 by concatenating
> "$quest" + $q[2] , etc.). In addition, I'd like to be able to execute
> these variables and echo the contents back to the screen (ie: for
> $quest1...echo "First", for $quest2...echo "Second", etc.
for($i=0; $i<4; $i++){
echo ${"quest".$q[$i]};
}
Navigation:
[Reply to this message]
|