Okay, I've been asked to take a bunch of HTML pages and turn them into Excel
spreadsheets by running them through a PHP script and outputting a
semicolon-delimited text file. The pages are in this format:

Name                : <b>LAST, FIRST MIDDLE</b>
Pilot's Address     : <b>ADDRESS LINE 1</b>
                      <b>ADDRESS LINE 2</b>
(Some stuff that doesn't go on the final spreadsheet)
Pilot Certificates  : <b>Pilot Certification</b>
                        <b>Sub-certification</b>
                        <b>Sub-certification</b>
                    : <b>Pilot Certification</b>
                        <b>Sub-certification</b>
                        <b>Sub-certification</b>

I don't know ANY regex, being a somewhat new PHP programmer, but using some
cut and paste, I've managed to get the name and address out like this:

<?php

$pilotlist = implode("",file("$zip.txt"));
$pilotarray = explode("<hr>",$pilotlist);

for ($x = 0; $x < count($pilotarray); $x++)
{
ereg("Name                : <b>(.*), (.*)</b>
Pilot's Address     : <b>(.*)</b>
                      <b>(.*)</b>
(.*):", $pilotarray[$x], $out);

$firstmid = explode(" ",$out[2]);
echo("$firstmid[0];");
if (count($firstmid)==2) echo($firstmid[1]);
echo (";$out[1];$out[3];$out[4]<br>");
}

?>

Now, stop laughing. I can't figure out how to add the pilot certifications
on there, since (.*) is just about the extent of my regex knowledge. Each
pilot on the list has a different number of certifications and
sub-certifications. If anyone can help at all, even if it's just pojnting me
to a good Regex tutorial, I'd be much obliged.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to