I have this array, $display_vars, and I want to split it into separate variables, so each variable's name is the array key, and it's value is the value, so to speak. So if the array was like this:
$display_vars = array(
'title' => 'something',
'header' => 'something else'
);
Then I want to end up with the equivalent of this:
$title = 'something';
$header = 'something else';
Can you think of any way I can possibly do this?
extract()
Be mindful about overwriting variables of the same name in the current scope. Read up on the second parameter if this is a concern.
Use
extract($display_vars);
http://php.net/manual/en/function.extract.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With