How to obtain the last word of a string

后端 未结 8 2222
囚心锁ツ
囚心锁ツ 2020-12-03 19:53

we have that string:

\"I like to eat apple\"

How can I obtain the result \"apple\" ?

8条回答
  •  一向
    一向 (楼主)
    2020-12-03 20:38

    $str = 'I like to eat apple';
    echo substr($str, strrpos($str, ' ') + 1); // apple
    

提交回复
热议问题