-1

I am creating an app for the company I work for. I need to pass data from the app (SWIFT) to PHP. The problem is the data I am passing is dynamic and can change. Heres an example

http://www.website.com/inventory.php?variable=data&variable=data

There are going to be different variables (up to 300). The names of the variables will change

How do I get all variables passes in php without necessarily knowing the names of them?

Is this possible? Thanks.

1 Answers1

1

Personally, I would suggest passing dynamic data items in an array via POST, not GET (see here), however if you want to get all the variables from the URL string, simply access the $_GET superglobal.

For example, the following code will output all the URL parameters:

print_r($_GET);

Input: file.php?item1=77&item2=99 would output

Array
(
    [item1] => 77
    [item2] => 99
)

If you want to get the data from this, then it would be easiest to loop over them in a foreach loop, like so:

foreach($_GET as $key => $value) {
    echo "Key: $key";
    echo "Value: $value";
}
llui85
  • 177
  • 2
  • 14