I've been trying to parse a string:
string = blah blah blah 'html/php code here' blah 'random code' blah blah.
I want nothing in the string except for the letters, numbers, spaces. I want all code stripped. I've been trying the strip_tags with success.
Next, I want to split the string into an array. I've been using explode. Some times it works, sometimes it doesn't. Any suggestions on how to do the above?
I don't need the string parsed into an array. All I need is the string to lack all outside code and just have the letters/numbers/spaces. Then I need to be able to echo the string line by line with a max of roughly 70 characters per line. I need some wordwrapping functionality so that it won't cut a word off halfway done with it. (IE: wo on one line and rd on the next.)
here is what I have so far with varied success:
$pictext = $output . $advertise;
$pictext = trim($pictext);
$pictext = strip_tags($pictext);
$rquote = explode("\n", wordwrap($pictext, 75, "<br />"));
$totlines = count($rquote);
from here I just use a while loop to echo the lines in the array. Sometimes it works right.
Then sometimes I get:
lost words
fragmented words
it doesn't break a line up at 75 chars, but more like 150.
parts of the <br /> display.
and other odd things.
Any help appreciated.
String parsing
Moderator: General Moderators