Search code examples
phpgetcatch-all

PHP GET catch all


Using the GET protocol with php I can get data passed to my program. With something like $_GET["fname"];.

What I'm wondering is there any way to make some sort of a catch all. Where I did not need to know the var name before runtime?


Solution

  • It's just an associative array, handle it like any other:

    foreach ($_GET as $name => $value) {
        echo "$name: $value\n";
    }
    

    If you just want "the first" value or "the one" value, do:

    $value = current($_GET);