myfile.php?Param1=Hi+there&Order=ColumnA&Param3=Bye+Bye
myfile.php?Order=ColumnA
myfile.php?Param1=Anotehr+example&Order=ColumnA
after applying this function, I'd like the result of the above examples
to be
myfile.php?Param1=Hi+there&Order=ColumnB&Param3=Bye+Bye
myfile.php?Order=ColumnB
myfile.php?Param1=Anotehr+example&Order=ColumnB
Thanks for your help, - Dave
<?php
$str = 'Param=Hi+there&Order=ColumnA&Param3=Bye+Bye';
parse_str($str, $ar);
if ($ar['Order']) {
$ar['Order'] = 'ColumnB';
}
$newstr = '';
foreach($ar as $key => $value) {
$newstr .= $key . '=' . urlencode($value) . '&';
}
print rtrim($newstr, '&');
?>