This article mainly introduces how php converts each column in an HTML table into an array to collect table data. It involves the php Regular Expression replacement technique and is very useful. For more information, see
This article mainly introduces how php converts each column in an HTML table into an array to collect table data. It involves the php Regular Expression replacement technique and is very useful. For more information, see
This example describes how php converts each column in an HTML table into an array to collect table data. Share it with you for your reference. The details are as follows:
The following php code converts each row and column of an HTML table into an array to collect table data.
<? Phpfunction get_td_array ($ table) {$ table = preg_replace ("' ] *?> 'Si "," ", $ table); $ table = preg_replace ("' ] *?> 'Si "," ", $ table); $ table = preg_replace ("' ] *?> 'Si "," ", $ table); $ table = str_replace (""," {Tr} ", $ table); $ table = str_replace (""," {Td} ", $ table); // remove the HTML Tag $ table = preg_replace (" '<[/!] *? [^ <>] *?> 'Si "," ", $ table); // remove the blank character $ table = preg_replace (" '([rn]) [s] + '","", $ table); $ table = str_replace ("", "", $ table); $ table = str_replace ("", "", $ table ); $ table = explode ('{tr}', $ table); array_pop ($ table); foreach ($ table as $ key => $ tr) {$ td = explode ('{td}', $ tr); array_pop ($ td); $ td_array [] = $ td;} return $ td_array;}?>
I hope this article will help you with php programming.
,