what is $_SERVER[‘QUERY_STRING’] ? how it works?

Explode : Returns an array of strings, each of which is a substring of string formed by splitting it on boundaries formed by the string delimiter.

array explode ( string $delimiter , string $string [, int $limit ] )

Run this Code to Understand :

/* A string that doesn't contain the delimiter will simply return a one-length array of the original string. */

$input1 = "hello";
$input2 = "hello,there";
var_dump( explode( ',', $input1 ) );
var_dump( explode( ',', $input2 ) );

The above example will output:

array(1)
(
    [0] => string(5) "hello"
)
array(2)
(
    [0] => string(5) "hello"
    [1] => string(5) "there"
)

And, In Your Case, Your Current Query String will be Splited into Array. And, Each / will be a array item.

Like if explode( ‘/’, ‘foo/bar’)

Array will contain Foo and Bar into seperate index.

For More : Explode : Explode Details from PHP.NET $_SERVER : $_Server Details from PHP.NET

Leave a Comment