Bir yolu kullanarak, "kelimeler" in dize patlayabilir olacaktır explode
or preg_split
(depending on the complexity of the words separators : are they always one space ? )
Örneğin:
$string = "R 124 This is my message";
$words = explode(' ', $string);
var_dump($words);
Bu gibi bir dizi olsun istiyorum:
array
0 => string 'R' (length=1)
1 => string '124' (length=3)
2 => string 'This' (length=4)
3 => string 'is' (length=2)
4 => string 'my' (length=2)
5 => string 'message' (length=7)
Sonra, ile array_slice
a>, sen (değil ilk iki olanlar) yalnızca istediğiniz kelimeleri tutmak:
$to_keep = array_slice($words, 2);
var_dump($to_keep);
Verir:
array
0 => string 'This' (length=4)
1 => string 'is' (length=2)
2 => string 'my' (length=2)
3 => string 'message' (length=7)
Ve, son olarak, birlikte parçaları koymak:
$final_string = implode(' ', $to_keep);
var_dump($final_string);
Hangi verir ...
string 'This is my message' (length=18)
And, if necessary, it allows you to do couple of manipulations on the words before joining them back together :-)
Actually, this is the reason why you might choose that solution, which is a bit longer that using only explode
and/or preg_split
^^