php从字符串中删除单词[关闭]

Suppose i have the following strin

assigned order 1234

I would like to remove the words

assigned order

So my final output should be

1234

How do i go about this in php

SO something like

$string = "assigned order 1234";

$newstring = //stuck here

NOte that the value 1234 can also be 767as33 BUT THE PART assigned order always remains constant

I would break into array of word, than take the last array item.

$words = explode(' ', $text); $orderno = end($words);

You should do a simple substring replacement:

$string = "assigned order 1234";
$newstring = substr_replace($string, '', 0, 15);//15 is the number of characters in 'assigned order '

echo 'new string: ' . $newstring;

http://php.net/manual/en/function.substr-replace.php