It's possible to use comma's in URLs for example: ?page=$page&id= 120
Instead of AND (&) we use comma
?page=$page,id= 120
Instead of AND (&) we use comma
?page=$page,id= 120
if (!empty($_GET) && count($_GET) == 1) {
$query_vars = array();
$query_data = explode(',', current($_GET));
if (!empty($query_data)) {
$query_vars[key($_GET)] = array_shift($query_data);
foreach ($query_data as $query_pair) {
if (!empty($query_pair)) {
$query_pair = explode('=', $query_pair, 2);
if (count($query_pair) == 1) {
$query_vars[$query_pair[0]] = null;
} else {
$query_vars[$query_pair[0]] = $query_pair[1];
}
}
}
}
$_GET = $query_vars;
}
/**
* Rebuild the superglobal $_GET array
*
* @param string $query_string The query string
* @param string $ampersand The replacement for ampersands in the query string
* @param string $equality The replacement for equality signs in the query string
* @return void
*/
function rebuild_get($query_string, $ampersand = '&', $equality = '=') {
if (!empty($query_string)) {
// Empty the $_GET array
$_GET = array();
// Insert key => value pairs into the $_GET array
foreach (explode($ampersand, $query_string) as $pair) {
$pair_data = explode($equality, $pair, 2);
$_GET[$pair_data[0]] = (count($pair_data) > 1) ? $pair_data[1] : null;
}
}
}
Comment