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

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -