0

I want to get last path of the URL Admin & Planner but this trim is not working for Planner it is giving Planne output. I tried searching couple of options on stackoverflow but its not working with me.
First URL : http://localhost/hydro-railway/Admin/
Output: Admin
Second URL : http://localhost/hydro-railway/Planner/
Output: Planne

$url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' 
            ? "https" 
            : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$url=trim($url,"http://localhost/hydro-railway/");
echo("after: ".$url."<br>");
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • 1
    Does this answer your question? [How to get the last path in a URL?](https://stackoverflow.com/questions/2273280/how-to-get-the-last-path-in-a-url) – Muhammad Faizan Uddin Jun 02 '21 at 10:55
  • 1
    Also check what `trim()` does with the second parameter - it's a list of chars to remove and not a specific string to remove. – Nigel Ren Jun 02 '21 at 10:57

0 Answers0