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
Post a Comment