Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4063870
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:46:56+00:00 2026-05-20T15:46:56+00:00

Solution? Apparently there isn’t a faster way, I’m okay with that. I am just

  • 0

Solution?

Apparently there isn’t a faster way, I’m okay with that.


I am just learning php and I am trying to figure out some good tips and tricks so I don’t get into a bad habit and waste time.

I am passing in values into a php script. I am using $_GET so the URL looks like this:

/poll_results.php?Sports=tennis&cat=Sports&question=Pick+your+favorite+sports

Now I know how to accept those values and place them into variables like so:

$sports = $_GET['Sports'];
$cat = $_GET['cat'];
$question = $_GET['question'];

Super simple yet if I am passing 5 – 6 things it can get bothersome and I don’t like typing things out for every single variable, that’s the only reason. I know there is a better way of doing this. I have tried list($var, $var, $var) = $_GET but that doesn’t work with an associative array just indexed ones (i think).

I also tried variable variables like so:

foreach($_GET as $value) {
    $$values = $value;
    echo $$values;
}

But that gave me a Notice: Undefined variable: values in poll_results.php on line 14. Line 14 is the $$values = $value. I don’t know if that’s a big deal or not… but I’m not turning off error reporting as I am still in the process of building the script. It does do what I want it to do though…

Any answers will be copied and pasted into my question so the next person knows 😀

Thanks guys!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T15:46:56+00:00Added an answer on May 20, 2026 at 3:46 pm

    Your second bit of code is wrong. It ought to be like

    foreach ($_GET as $key => $value) {
        $$key = $value;
    }
    

    if i understand your intent. However, you’re basically reinventing register_globals, which….eh. That’ll get ya hacked.

    If you have certain variables you want to get, you could do like

    foreach (array('Sports', 'cat', 'question') as $key)
    {
        $$key = $_GET[$key];
    }
    

    which is less likely to overwrite some important variable (whether by accident or because someone was messing around with URLs).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Solution Edit: Turns out you can't use the PHP SDK to return the correct
I've been trying to figure this out and so far haven't found a simple
Apparently there is an expired certificate on a site that I use for automated
SOLUTION Make sure in the plist that the storyboard name is listed as the
Solution: strpos turned out to be the most efficient. Can be done with substr
Overview Are there explanations for Control.BeginInvoke() to not execute a delegate that it is
I was hoping this would be simple, but apparently every solution on the web
So I wrote a script in PHP that requires JavaScript to run with it.
Until a test I've just made, I believed that only Constructors were not inherited
There is apparently a bug in Android which breaks View.bringToFront . If I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.