I have a function that returns an array of variables. The variables it returns vary depending on what it needs to return. For example one time it could return array($pet,$color); and another time it could return array($height,$width,$table);
On the receiving end I want to make these variables available. If I knew I was expecting $pet and $color, I could do something like
list($pet, $color) = myfunction();
but I don’t know what the function is going to return each time. So is there a way I could still recreate these variables under the same names when I receive the function output?
Edit: I was hoping to not have to do it by defining an associative array that has the name of the variable saved as a string in addition to the variable itself.
Does the function return an associative array, eg
If so, you can then use the
extractfunction to bring each entry into the current scope’s symbol table