/ Published in: PHP

This simply takes an array and coverts it to variables. E.g. If you had an array, $array = array("key" => "value"), after running this script, $key would be "value".
Expand |
Embed | Plain Text
<?php foreach($array as $key => $value){ $$key = $value; } // simple as that
Comments

You need to login to post a comment.
Even simple if you just use the PHP extract() function, no loop.
Thanks for the tip. extract() is a lot shorter.