hukadeeze Posted February 28, 2007 Share Posted February 28, 2007 I'm sure this is a pretty basic question, but I used search and could not find anything. Probably because I don't know exactly what I'm looking for. Here's my problem. I'm creating an array and want the key to have the same name as the variable I'm using for that keys value. $variable = 'value'; $somearray = array( ' ? ' => $variable ); Basically where the question mark is I want it to pull the word ' variable ' from the variable $variable and use it as the key. The purpose of this is I'm passing unknown (unknown inside the function that is) params to a function that loops through these params and enters them into an array which is returned from the function. Subsequent code will know what is needs from $somearray. Quote Link to comment https://forums.phpfreaks.com/topic/40592-solved-copy-variables-name/ Share on other sites More sharing options...
hukadeeze Posted March 1, 2007 Author Share Posted March 1, 2007 bump? ??? Quote Link to comment https://forums.phpfreaks.com/topic/40592-solved-copy-variables-name/#findComment-196555 Share on other sites More sharing options...
fert Posted March 1, 2007 Share Posted March 1, 2007 http://us2.php.net/manual/en/function.extract.php Quote Link to comment https://forums.phpfreaks.com/topic/40592-solved-copy-variables-name/#findComment-196556 Share on other sites More sharing options...
hukadeeze Posted March 1, 2007 Author Share Posted March 1, 2007 Well, you were close in the sense that you set me on the right track! I was looking for compact(), not extract(), but I didn't know of either of these functions and will find them very useful. Thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/40592-solved-copy-variables-name/#findComment-196560 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.