Chloe Shoots Lazers
Chloe Shoots Lazers

Reputation: 13

PHP - Certain GET Usage

So I have my links set like:

https://hidden.io/buy?minecraft&pc

Tried:

$_GET[0], $_GET[1]
var_dump() showed me that GET doesn't function like that.

Website example using this way of GET already:

https://namemc.com/s?ChloeKitty
(S is a Directory)

Im not looking for stuff like:

https://hidden.io/buy?game=minecraft&platform=pc

How could I make it so I can make a usable array like:

$array[0] // "minecraft"
$array[1] // "pc"

Upvotes: 0

Views: 38

Answers (3)

EugeneSantos
EugeneSantos

Reputation: 368

You can use the PHP built-in function to parse query string parse_str()

parse_str($_SERVER["QUERY_STRING"], $output);
array_keys($output);

Upvotes: 1

Mihai Matei
Mihai Matei

Reputation: 24276

Try it like:

$myArray = explode('&', $_SERVER["QUERY_STRING"]);

Upvotes: 1

Professor Abronsius
Professor Abronsius

Reputation: 33823

Try:

print_r( array_keys( $_GET ) );
$vars=array_keys( $_GET );
echo $vars[0]; /*etc*/

Upvotes: 0

Related Questions