I have this old class written for <php5 which has a method which takes and unknown array and creates and propegates object variables for each array item and then uses those values throughout the class.
Since the PHP5 upgrade, it has stopped working and I assume it's the new object model. So here's the code....
class myClasas
{
....some other stuff....
//here's the method ... getVars ... takes $VARS array and turns the array into variables
function getVars($VARS) {
if (is_array($VARS)){
foreach ($VARS as $key => $val) {
$this->{$key} = $val;
}
}
}
}
/*
so if I pass an array like
$VARS = array(
"apples"=>"good",
"oranges"=>"bad");
I could say in the class...
echo $this->apples;
But I could also pass a completely different array and have the rest of the methods not rely on exact array keys.
*/
It's probably bad code but it allows me to get the variables later on with the old...
$this->variable
with me not knowing what $this->variable will be.
So, can you figure out how to fix this?