note 35807 added to reserved.variables
| From: | rsalazar at universia dot net dot mx | Date: | Mon, 15 Sep 2003 13:01:02 +0000 |
| Subject: | note 35807 added to reserved.variables | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-56525@lists.php.net to get a copy of this message | ||
Yet another version of this function. I've been using this one and seems to work just fine.
It adds (if it doesn't exist) or replaces (if it exists) the $value of the $param on the $query
:) If $ceol (cleanEndOfLine) is evaluated as TRUE and the $param is found, anything after that will
be deleted don't ask, it was useful... once
<?php
function replaceOnQueryString( $query, $param, $value = NULL, $ceol = FALSE )
if( !is_null($value) && !preg_match('/(^|\?|&)'. $param .'=/i',
$query) )
return $query .($query ? '&' : ''). $param .'='. $value;
$pattern = '/(^|\?|&)('. $param .((bool)$ceol ? ')=.*$/i' :
')(=[^&]*)?/i');
return preg_replace($pattern, is_null($value) ? '' : '$1$2='. $value,
$query);
}
?>
I'm not sure if I'm keeping it simple or making difficult what already is simple, but here
you have anyway
----
Manual Page -- http://www.php.net/manual/en/reserved.variables.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35807
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35807&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35807&report=yes