i hate to say this, but perl has a great module for parsing tables that you might want to look into. i had to parse 5,000 pages with over 100,000 entries and the html::tableextract module was excellent for the job ;o)
just another opinion, i still write 99% of everything in php, but i might as well use something that already works great than me struggling with it for hours on end hoping it will work ;o)