Sometimes we need to keep get and post parameters passed on the next page or other uses!
The convenience of work so I wrote this code!
I hope we can communicate a lot!
?
/*
Program Design: Lin Jianxui (fluttering maple design room)
Made in Zhuhai by 2007-03-24
qq:5818500
Email:linzhenxuan@163.com
Do not delete this copyright information
Purpose: Keep and modify get and Post parameters
*/
Function getplus ($x = ', $value = ', $plus = ' close ', $method = ' all ')
{
Global $_get,$_post;
$array = Array ();
if ($method = = ' All ')
{$array [] = $_get; $array [] = $_post;}
ElseIf ($method = = ' Get ') {$array [] = $_get;}
ElseIf ($method = = ' Post ') {$array [] = $_post;}
$a = $_get;
$i = 1;
$true = 0;
foreach ($array as $k => $a)
{
foreach ($a as $b => $c)
{
if ($b = = $x)
{
$c = $value;
$true = 1;//found it.
$true 2 = 1;
}
if ($plus = = ' Close ')
{
if ($i ==1)
{
$temp. = "$b = $c";
}
Else
{
$temp. = "& $b = $c";
}
}
Else
{
if ($i ==1)
{
if ($true 2!=1) {$temp. = "? $b = $c";} else{$temp. = "?"; Unset ($true 2);}
}
Else
{
if ($true 2!=1) {$temp. = "& $b = $c";} Else{unset ($true 2);}
}
}
$i + +;
}
}
if ($true ==0)
{
if (Strpos ($temp, "?") >0 | | Strpos ($temp, "=") >0)
{
$temp. = "& $x = $value";
}
Else
{
$temp. = "$x = $value";
}
}
ElseIf ($true ==1 && $plus!= ' close ')
{
if (Strpos ($temp, "?") >0 | | Strpos ($temp, "=") >0)
{
$temp. = "& $x = $value";
}
Else
{
$temp. = "$x = $value";
}
}
return $temp;
}
?>
Like the original
Get:? method=1&a=1&b=2
post:y=2007&m=03
used the
<?=getplus (' C ', ' 3 ')?>
Show after
? method=1&a=1&b=2&y=2007&m=03&c=3
used the
<?=getplus (' A ', ' 3 ', ' open ')?>
Show after
? method=1&b=2&y=2007&m=03&a=3
Drag the a=3 to the bottom.
I use <?=getplus (' A ', ', ', ' open ') to?> with JavaScript
Previous page
I feel pretty good about myself!
Maybe there's a bug you didn't find!
I hope you have a lot of mention!