Does anyone have a script to pull a value from a database that has RTF codes and convert it to plain text?
Strip RTF Codes from Variable
From a google search, I found this:
Example:
require("parser.class.php");
function remove_rtf($rtf) {
$r = new rtf(stripslashes($rtf));
$r->output("html");
$r->parse();
if(count($r->err) == 0)
return strip_tags($r->out);
}
Hopefully it works
Thanks! I don't know how you even found that. It looks cool, but it seems to just strip the slashes out plus the first character after the slash. I can't get it to work as it appears to be intended. If you can get it to work, let me know. Looks like a good idea.
Thanks!
Jim
Okay, I didnt try the example until now..
I removed the stripslashes from the $r = new rtf() statement:
function remove_rtf($rtf) {
$r = new rtf($rtf);
$r->output("html");
$r->parse();
if(count($r->err) == 0)
return strip_tags($r->out);
}
Of course there is now a downside, I didnt realize this about the way it converts it, but it all goes to one single line, making it faintly effective at converting to HTML.
The Class is a VERY good start, and could probably be modified to suit your needs, its too much for me to do (I am @ work).