Simple PHP question – how to parse a url string
-
$url = ‘/devel/lms/ja/lessons/planning-a-meeting-int/’
how can I parse this such that:
$new_url = ‘/lessons/planning-a-meeting-int/’
I was expecting THIS to work:
$my_array = explode(“/”,$url,4);
//uses the optional 3rd parameter of the explode function
//https://www.geeksforgeeks.org/php-explode-function/$new_url = implode(‘/’.$my_array[3]);
//uses the implode function to add back the preceding slash
//and convert the array item back to a stringWhat am I doing wrong?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Simple PHP question – how to parse a url string’ is closed to new replies.