Hi!
I have a problem with parsing html table.
I need a script witch will pars html table from one site to another.
Can somebody help me with that??
can u secefy that, maybe give an example of the html-table (input and output) and the already existing code?
basicly u just use file_get_contents and regex or strpos/substr.
http://php.net/file_get_contents
http://php.net/regex
http://php.net/strpos
http://php.net/substr
Example of a table
<table width="200" border="0"> <tr> <td>1</td> <td>2</td> <td>3</td> </tr> <tr> <td>a</td> <td>s</td> <td>q</td> </tr> <tr> <td>b</td> <td>d</td> <td>w</td> </tr> <tr> <td>c</td> <td>f</td> <td>e</td> </tr> <tr> <td>d</td> <td>v</td> <td>r</td> </tr> </table>
I dont have a php Code example .
I need a dynamic html table parse. So if data in table would be changed on original table, the table data of parsed table will be changed too. Sorry for my english =)
mby someone have a ready parsing table script??
wi hardly have any ready made scripts, as this side is made to help people with teyr scripts.
if u try to write ur own we are able to help u, but if u are just searching for something thats alrady done http://www.google.de is the right page for u.
a script to collect a table like this into an array should be quite easy:
something like (not ment to be working):
[php]
$table=’
$array=array();
$i=0;
while(($tr_start=strpos($table,’<tr’))!==false)
{
$tr_start=strpos($table,’>’,$trstart+3);
$tr_end=strpos($table,’’,$tr_start);
$tr=substr($table,$trstart,$tr_end-$tr_start)
$array[$i]=array();
while(($td_start=strpos($tr,’<td’))!==false)
{
$td_start=strpos($tr,’>’,$tdstart+3);
$td_end=strpos($tr,’’,$td_start);
$td=substr($tr,$tdstart,$td_end-$td_start)
$array[$i][]=$td;
$tr=substr($tr,$td_end+5)
}
$table=substr($table,$tr_end+5)
$i++
}
[/php]
written in about one minute. of couse this cript will malefunction if any 's or 's are missing.
Script requests are not-done and not appreciated. We can help you troubleshoot your own scripts or help you on the way by providing pseudocode (see Q1712’s post), but we’re not here to do your work for you. Please keep that in mind when posting.