Entry
How can I translate preformatted text to HTML code in PHP?
Mar 21st, 2001 10:08
Hardy Pottinger, Matt Gregory, Jonas Larsson,
There are several functions in PHP which allow you to convert symbols
like the < and > to < and > as well as other html specific
functions.
(Please refer to http://www.php.net/manual/html/ref.strings.html )
In order to turn other text into html you have a lot of work ahead of
you. There is some talk among the developers of PHP to include some
HTML formating functions. (for instance char * rtftohtml(char *rtf)).
There is a lot of work involved in completing that and other functions
like it however, so I would be surprised if you will see it in the
first release of Zend (PHP4).
If you wish to write your own function to do this, all I can give you
is a little push in the right direction:
Step 1: Decide on a common format for the file or strings you wish to
convert. (For instance RTF)
Step 2: Decide on common converters for each font size, color, string
positioning, and all other format characteristics of the file type you
are importing.
Step 3: Sit down and pound out all the conversion functions. This will
take you the better part of a week to finish, no matter how fast you
code.
Step 4: Publish your code on the web so the rest of us won't have to do
it!!!!!!!!
---
If you'd like a shortcut to getting some of this hard work done, check
out wvWare (http://wvware.sourceforge.net/) and the Wotsit's Format
programmer's resource page (http://www.wotsit.org/).