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

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -