0

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

2
  • I don't understand why you would want to pass around 100 variables instead of one array. Commented Oct 27, 2009 at 4:47
  • because the rest of my code is written in those variables Commented Oct 27, 2009 at 4:51

3 Answers 3

4

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.

Sign up to request clarification or add additional context in comments.

Comments

3

https://www.php.net/extract

Comments

3

You probably don't ultimately want to do that, but the extract() function does this.

https://www.php.net/manual/en/function.extract.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.