[thelist] PHP and Regular expression Help.
Donald Noble
donald at drnoble.co.uk
Mon Jul 1 13:55:01 CDT 2002
Hi evolters, I am trying to parse a plain text document to give a simple
html file. (on a windows machine)
the file has headings in BLOCK CAPITALS with 2 line breaks between
paragraphs.
So far I have this...
<?
$fileContents =
fread(fopen($fileName,'rb'),filesize($fileName));
$fileContents = htmlentities($fileContents); // convert & to
& etc.
$fileContents = ereg_replace("^","<p>","$fileContents"); //start
with a <p>
$fileContents = ereg_replace("$","</p>","$fileContents"); //end
with a </p>
$fileContents =
ereg_replace("(\r\n){2}","</p>\r\n<p>","$fileContents"); // double line
break to </p><p>
?>
The problem I have is how to convert the headings to have <h3></h3>
round them...
Cheers for your help :Donald
--
http://www.AccessibleComputers.co.uk
Hardware, Software & Custom built PC Systems
More information about the thelist
mailing list