Created
September 24, 2017 12:59
-
-
Save isu3ru/4d875aef02f1709d0fdb0d626f95803d to your computer and use it in GitHub Desktop.
Reload current url with some parameters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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