php - Get last 3 words from the string? -


how last 3 words string?

i managed working doing this:

$statusmessage = explode(" ", str_replace(' '," ",$retstatus->plaintext)); $slicedate = array_slice($statusmessage, -3, 3); $date = implode(" ", $slicedate); echo $date; 

is there shorter way? maybe there php function did not know..

explode() good, once you've done can use

$size = sizeof($statusmessage); 

and last 3

$statusmessage[$size-1];  $statusmessage[$size-2];  $statusmessage[$size-3];  

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -