$string = "Hello World Again". echo strrchr($string , ' '); // Gets ' Again'
Now I want to get "Hello World" from the $string [The substring before the last occurrence of a space ' ' ]. How do I get it??
$string
This is kind of a cheap way to do it, but you could split, pop, and then join to get it done:
$string = 'Hello World Again'; $string = explode(' ', $string); array_pop($string); $string = implode(' ', $string);
1.4m articles
1.4m replys
5 comments
57.0k users