Basically, what I want is like this creating variable names from an array list
But it's the other way around, instead of creating normal variables, I want to create arrays from the variable values
Basically, what I want is like this creating variable names from an array list
But it's the other way around, instead of creating normal variables, I want to create arrays from the variable values
If you want to make an array which maps variable names to their values, use compact(), passing variable names as strings:
$one = 1;
$two = 2;
$variables = compact('one', 'two'); // Array ( [one] => 1, [two] => 2 )
If all you want is an array containing the values of your variables, just make a normal array using array() and toss your variables in:
$one = 1;
$two = 2;
$variables = array($one, $two); // Array ( [0] => 1, [1] => 2 )