Posted by samudas on 11/18/18 11:41
This is really ugly and there's probably a better way. In php5 it would
be a piece of cake because you'd have the http_build_query function.
You might also try using a regex. I'm going to trust that you know how
to get the query string yourself.
<?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, '&');
?>
Navigation:
[Reply to this message]
|