Splitting html string after so many words

Posted by jimbo on Stack Overflow See other posts from Stack Overflow or by jimbo
Published on 2010-06-10T09:46:19Z Indexed on 2010/06/10 11:02 UTC
Read the original article Hit count: 141

Filed under:

Hi all,

I have a string that if it is longer than lets say 10 words, I want to split it into two parts. The second part will be included else-where after a 'more' link.

The string will hold html tags too though. For an example the string could be:

<p>This is just a test string with more words than the <strong>amount allow</strong> before split, blah blah blah</p>

So in the case I would want:

$string[0] // <p>This is just a test string with more words than</p>;
$string[1] // <p>the <strong>amount allow</strong> before split, blah blah blah</p>;

Thanks in advance

© Stack Overflow or respective owner

Related posts about php