tommytx Posted October 6, 2016 Share Posted October 6, 2016 I have used this command before and cannot remember the name or how to deploy it.. sorta like implode but different.. what it does is take an associative array and makes individual variables out of the array like this. $str = arrray("dog->catkiller", "house->placetolive:) and when applied results in the following.$dog = "catkiller"; $house = "placetolive"; Can anyone help me with this.. I need the command name and a sample of its use.. Quote Link to comment https://forums.phpfreaks.com/topic/302289-what-is-the-command-similar-to-implode-explode-and-etc/ Share on other sites More sharing options...
Solution CroNiX Posted October 6, 2016 Solution Share Posted October 6, 2016 extract($str) is what you're looking for. Takes an array and breaks it up into individual variables using the keys of the array as the variable names. http://php.net/manual/en/function.extract.php Quote Link to comment https://forums.phpfreaks.com/topic/302289-what-is-the-command-similar-to-implode-explode-and-etc/#findComment-1538083 Share on other sites More sharing options...
tommytx Posted October 6, 2016 Author Share Posted October 6, 2016 Thanks that is exactly the word.. just could not remember for the life of me and i searched around the explode and implode areas but never saw any ref to it.. so totally slipped my mind.. what little i got left.. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/302289-what-is-the-command-similar-to-implode-explode-and-etc/#findComment-1538084 Share on other sites More sharing options...
Jacques1 Posted October 6, 2016 Share Posted October 6, 2016 For the record: extract() is a terrible function which should not be used in any kind of serious code. Flooding the symbol table with dynamic variables is not only unnecessary, unclean and error-prone. It can fudge up your entire security if the data is user-controlled. When you have an associative array of data, simply keep it that way. No reason to turn it into a set of variables. 1 Quote Link to comment https://forums.phpfreaks.com/topic/302289-what-is-the-command-similar-to-implode-explode-and-etc/#findComment-1538085 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.