Justtechjobs.com Find a programming school near you






Online Campus Both


php-general | 2000071

Re: [PHP] HTML Table into 2D array From: Richard Lynch (richard <email protected>)
Date: 07/03/00

In article <4.2.0.58.20000703202712.00c3ce30 <email protected>>,
adamcharnock <email protected> (Adam Charnock) wrote:

> Hello. Does anyone know if it is possible to convert a HTML table into a 2D
> array? Or is there some code snippet out there that does it for you?

Here's a start:

$html = "<TABLE><TR><TD>a</TD><TD>b</TD></TR><TD>1</TD><TD>2</TD></TR></TABLE>";

$rowdata = pregi_replace("<TABLE*>", "", $html);
$rowdata = pregi_replace("</TABLE>", "", $rowdata);
$rows = pregi("<TR*>", $rowdata);
while (list($index,$row) = each($rows)){
  $rows[$index] = pregi("<TD*>", $row);
}

Disclaimer: You can be pretty certain I got the Regex all wrong :-)

-- 
Richard Lynch                | If this was worth $$$ to you, buy a CD
US Customer Support Director | from one of the artists listed here:
Zend Technologies USA        | http://www.L-I-E.com/artists.htm
http://www.zend.com          | (this has nothing to do with Zend, duh!)

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>