Discussion on:

9
Comments

Join the conversation!

Follow via:
RSS
Email Alert
0 Votes
+ -
Editor
Have you ever been presented with this particular conversion problem? How did you solve it? Do you have different script you could share with TechRepublic members?
0 Votes
+ -
php4?
bruce@... 28th Jul 2006
Great article!
However, on my main site I have php4 and have been struggling to re-interpret this script to create and write a new html file.

Any tips?

Thank you for a great article
0 Votes
+ -
Thanks
bruce@... 14th Aug 2006
Why bother having comments and wasting peoples time if you don't answer?
0 Votes
+ -
1. Why remove extra spaces? What's the point of that? Display by a browser automatically reduces additional whitespace so that only a single space is displayed. It's part of the (X)HTML standard. That's a waste of a line of code.

2. I can understand the header and footer code for generating static HTML pages, but if all you're going to do is echo the content of your variable to the browser, you might as well just add the headers and footers at the beginning and ending of the script as it is. Alternatively, you can separate functionality for reuse by other scripts, and just echo the actual main body text, then have a separate file with the headers and footers as a static part of that other file and an include() or require() statement to call your text formatting file.
0 Votes
+ -
Thanks a lot for the script. My immediate challenge is to convert Msword doc(i.e .doc) files to HTML.
I do not want to use COM or DOM as my version of PHP(ver 4.3) do not support it.
Do you have any ideas. I always get lots of gabbage when I try the rendering of word to html or text
0 Votes
+ -
It is true that you get a lot of gargbage when you use Word to save a document in HTML format. However, the HTML page usually looks pretty clean when viewed in a browser (at least it does when viewed in IE...go figure). But if you ever want to maintain it or add or remove something from the HTML, you have to struggle through all the extra tags that Word creates. You could try saving to a text document then applying the rules that Mr. Kaelin referred to at the beginning of this discussion.
How do you transform this whole code froM HTML TO PHP using markup language
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">



AOM

#container{
width: 610px;
text-align: left;
margin: 0 auto auto auto;
padding: 0 auto auto auto;
}








Name: (required)



Phone: (required, only numbers ex: 5553338899)



Select Your City

Atlanta

Chicago

Houston

Los Angeles

New York



Select your language

English

Spanish







Official Rules




©2008 America On the Move Foundation, Inc. All Rights Reserved.








0 Votes
+ -
Thank you very Much Tha was What I was looking for, may God bless you a lot
This is great if you only have two hyperlink references in the initial text file. If there are more than two, it breaks and all remaining text is treated as part of the second http address.

With a bit more tinkering with the expression syntax, I've now managed to get it to haul out any amount of hyperlinks from a text file with the following:

$html = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.-]*(\?\S+)?)?)?)@', ' Click Here For Details', $html);
Keyboard Shortcuts:
Prev
Next
Toggle
Join the conversation
Formatting +
BB Codes - Note: HTML is not supported in forums
  • [b] Bold [/b]
  • [i] Italic [/i]
  • [u] Underline [/u]
  • [s] Strikethrough [/s]
  • [q] "Quote" [/q]
  • [ol][*] 1. Ordered List [/ol]
  • [ul][*] · Unordered List [/ul]
  • [pre] Preformat [/pre]
  • [quote] "Blockquote" [/quote]

Join the TechRepublic Community and join the conversation! Signing-up is free and quick, Do it now, we want to hear your opinion.