How to remove the last part of a URL after the last slash (/) in PHP

1 Answer

0 votes
$url = "http://www.website.com/abc/xyz";
         
$url = substr($url, 0, strrpos($url, '/'));
  
echo $url;
 
 

  
/*
run: 
 
http://www.website.com/abc
 
*/
    

 



answered Feb 21, 2020 by avibootz

Related questions

2 answers 321 views
1 answer 261 views
2 answers 284 views
1 answer 193 views
1 answer 170 views
...