Skip to content

Instantly share code, notes, and snippets.

@isu3ru
Created September 24, 2017 12:59
Show Gist options
  • Save isu3ru/4d875aef02f1709d0fdb0d626f95803d to your computer and use it in GitHub Desktop.
Save isu3ru/4d875aef02f1709d0fdb0d626f95803d to your computer and use it in GitHub Desktop.
Reload current url with some parameters
<?php
function reloadUrlWithParams($anchor = false, $params = false)
{
$temparr = array();
if ($params && is_array($params)) {
foreach ($params as $k => $v) {
$temparr[] = urlencode($k) . "=" . urlencode($v);
}
}
$url = $_SERVER['PHP_SELF'] . ($anchor ? $anchor : '') . ((!empty($temparr)) ? "?" . implode("&", $temparr) : "");
return $url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment