al9 — 2007-12-13T04:52:36-05:00 — #1
I'm cutting first 400 symbols from the text and I'd like to remove from the result string last word. I wonder is there built-in PHP function that will cut all letters until " " (space) symbol starting from the end of the string?
stereofrog — 2007-12-13T05:16:00-05:00 — #2
$b = substr($a, 0, strrpos($a, " "));
$b = preg_replace('~\\s+\\S+$~', '', $a);
will remove the last "word". It would be perhaps simpler just to cut first, say, 40 words instead of 400 symbols. Search the forums, this has been discussed many times before.
al9 — 2007-12-13T05:58:30-05:00 — #3
Thank you very much for advice.
strrpos() works perfectly.