Convert each line of HTML table to CSV format array
?
function Get_tr_array ($table) {
PHP Tutorial Open Source code
$table = Preg_replace ("' <td[^>]*?> ' si", ' "', $table);
$table = Str_replace ("</td>", ' ", ', $table);
$table = Str_replace ("</tr>", "{tr}", $table); Open Source Code osphp.com.cn
Get rid of HTML tags
$table = Preg_replace ("' <[/!] *? [^<>]*?> ' Si ', "", $table);
Remove white space characters
$table = Preg_replace ("' ([RN]) [s]+ '", "", $table);
$table = Str_replace ("", "", $table);
$table = Str_replace ("", "", $table);
$table = Explode (", {tr}", $table);
Array_pop ($table);
return $table;
}
?>
To convert each row of HTML tables into an array, collect tabular data
?
function Get_td_array ($table) {
$table = Preg_replace ("' <table[^>]*?> ' si", "", $table);
osphp.com.cn
$table = Preg_replace ("' <tr[^>]*?> ' si", "", $table);
$table = Preg_replace ("' <td[^>]*?> ' si", "", $table);
$table = Str_replace ("</tr>", "{tr}", $table); Open Source Code osphp.com.cn
$table = Str_replace ("</td>", "{td}", $table);
Get rid of HTML tags
$table = Preg_replace ("' <[/!] *? [^<>]*?> ' Si ', "", $table); osphp.com.cn Open Source
Remove white space characters
$table = Preg_replace ("' ([RN]) [s]+ '", "", $table);
$table = Str_replace ("", "", $table);
$table = Str_replace ("", "", $table);
$table = Explode (' {tr} ', $table);
Array_pop ($table); PHP Open Source Code
foreach ($table as $key => $tr) {
$TD = Explode (' {TD} ', $TR);
Array_pop ($TD);
$TD _array[] = $TD; // }
return $TD _array;
}
?>