how to get a specific word out of string in php -


i working on wordpress plugin. want url of website , page name out of www.example.com/pagename in case want pagename. used native php function $_server['request_uri'] url of website. stored in $url variable shown below.

$url= $_server['request_uri']; 

i when echo url var

/ifar/wellington/  $name= "wellington"; /* want */  

how can wellington out string , store in $name.

actually should use router, https://github.com/auraphp/aura.router or other. simple , quick answer

$parts = explode('/', trim($url, '/')); $name = $parts[1]; 

if want 2nd uri segment.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -