Reputation: 21197
I am running this mysql query:
$result = mysql_query("SELECT * FROM userdetails WHERE userid= '$userid'");
$row = mysql_fetch_array($result);
The result is a row of 100 variables with different names such as $row['name'], and $row['email'], etc...
How can I convert all of these to just $name and $email, etc... in php?
It would save so much time to write this program....
Upvotes: 0
Views: 1015
Reputation: 450
Short anwser: extract
long anwser : don't. It may seem like a good anwser now but if you use it much it will become a problem keeping track of stuff.
Upvotes: 4
Reputation: 5069
You probably don't ultimately want to do that, but the extract() function does this.
https://www.php.net/manual/en/function.extract.php
Upvotes: 3