Jump to content

[SOLVED] Copy Variables Name?


hukadeeze

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/40592-solved-copy-variables-name/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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