I have a set of punctuation characters:
$punctuation = array('.', '!', ';', '?');
A character limit variable:
$max_char = 55;
And a string with HTML:
$string = 'This is a test string. With <a href="http://google.com">HTML</a>.';
How can I split this string to maximum $max_chr
characters, using one of the characters in the $punctuation
array as "keys" ?
So basically the string should split at the nearest punctuation character, but not inside a HTML tag definition/attribute (It doesn't matter if the split occurs inside a tag's contents and the tag remains unclosed -- because I'm checking for unclosed tags later).