Decrease

[b]code[/b]
echo $_SERVER['QUERY_STRING']

[b]result[/b]
"a1=1&a2=2&a3=3&a4=4&a5=5"

Let’s suppose the code above produces the result above.

With the QUERY_STRING above, I like to produces my target below.

[b]target result[/b]

"a1=1&a2=2&a3=3&a4=4&a5=5"

"a1=1&a2=2&a3=3&a4=4"

"a1=1&a2=2&a3=3"

"a1=1&a2=2"

"a1=1"

The trial code below doesn’t work correctly, but I hope it show what I want.

[b]trial code[/b]

$string=$_SERVER['QUERY_STRING'];

$delimiterCount=strlen($string)-strlen(str_replace("&","",$string) );

$whileString=$string;
$whileI = $delimiterCount+1; 

while($whileI > 0)
{
echo $whileString."<br>";

$whileString=str_replace('"&a".$whileI."=".$_GET['a'.$whileI]','[COLOR="Red"]'[/COLOR],$whileString);

$whileI--;
}

You already have a thread for which matches the context of your question http://www.sitepoint.com/forums/php-34/variables-inside-parameter-names-771959.html