Jump to content

What is the command similar to implode, explode and etc.


Go to solution Solved by CroNiX,

Recommended Posts

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..

 

  • Solution

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

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.

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.

  • Like 1
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.