Naming A Variable With Another Variable?

SpaceshipSpaceship
SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Watch

beaver6813

Established Member
Impact
16
Hey,

PHP:
$query = mysql_query("SELECT * FROM `table`");
$setprep = mysql_fetch_assoc($query);
foreach ($setprep as $key=>$value) {
$keyname = "$key";
$keyname = $value;
}
^^^^^< Doesn't work :(

Basically its retrieving settings from a database, i need it to name the variable based on its $key. But its all quite confusing and i can't figure out how to do it. I know i can do it with an array, say $settings[$key]. But i just want the seperate variables. Is it possible?

So all i want is the key as the variable name.
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
1
Close
Aha ;) Worked it out just before you posted. Thanks a lot though nice to know you guys are here for me ^^ _\|/_
 
0
Close
AIVikingsAIVikings

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

A browser tab with a favicon next to the page title
Search members
You can now search for members by name, company, location and more. Open the search at the top of any page and choose Members. You will...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back