QUESTION : $host = ltrim($_SERVER['REQUEST_URI'], '/'); this remove prefix "/" from URL i also need the suffix "?page=*" removed eg : /city?page=4 becomes city /sydney?page=444 becomes sydney etc
urlencode
urldecode
Quote:urlencode($your_string) — This PHP function is encodes a string to be used in a query part of a URL. URL encoding is used when placing text in a query string to avoid it being confused with the URL itself.
Quote:urldecode($your_string) — This PHP function is decodes the query part of a URL string.
$url = "https://sample.ex/home.php?queryparam=all about php"; $encodedUrl = urlencode($url); //returns http%3A%2F%2Fsample.ex%2Fhome.php%3Fqueryparam%3Dall+about+php echo $encodedUrl; //returns https://sample.ex/home.php?queryparam=all about php echo urldecode($encodedUrl);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)