yii2 - How to remove first word from string that ends with forwordslash(/) in php -


$pathinfo = $_server['redirect_url']; 

this code , return:

/google/agency/create 

however, need agency/create /google dynamic word.

you can explode url string, unset first value , implode again.

<?php  $url = "/google/agency/create";  $exp = explode("/", trim($url, "/")); // trim '/' url , explode unset($exp[0]); // unset first value $final_arr = implode("/", $exp); // form string again  print_r($final_arr);  ?> 

output:

agency/create

working example


Comments

Popular posts from this blog

How to check data type in C++? -

javascript - Is getTimezoneOffset() stable during daylight saving transition? -

sql server - SQL Query returns one result, does not return 0 or NULL result -