Page 1 of 1

Creating a new variable

Posted: Wed Nov 07, 2007 4:27 am
by aceconcepts
Hi,

How would one assign values to a dynamically created variable?

Normally one would declare a variable before it is used. However, if you have a foreach loop can you create a variable for each value found in an array

i.e.

Code: Select all

foreach($arrArray as $varValue)
{
   if(array_search("someValue", $otherArrayToSearch)===true) create new variable here from $varValue;
}

Posted: Wed Nov 07, 2007 1:41 pm
by Kieran Huggins

Posted: Wed Nov 07, 2007 5:22 pm
by feyd
Variable variables would be better here, although I don't like using either.

Posted: Wed Nov 07, 2007 6:35 pm
by Kieran Huggins
just about anything that can be done with variable variables can be done better with an array.

Why do you need to extract values from the array in the first place?