Hello I've succesfully parsed some tables from an html page using this code:
foreach($html->find('table') as $table) {
echo '<table>';
echo $table->innertext;
echo '</table>';
}
Now I'd like to parse some more code, look at the source html below:
<h5>.....</h5>
<table>.....</table>
<h5>.....</h5>
<table>.....</table>
<h5>.....</h5>
<table>.....</table>
I tried this code:
foreach($html->find('h5') as $h5) {
echo '<h5>';
echo $h5->innertext;
echo '</h5>';
}
foreach($html->find('table') as $table) {
echo '<table>';
echo $table->innertext;
echo '</table>';
}
This is the output:
<h5>.....</h5>
<h5>.....</h5>
<h5>.....</h5>
<table>.....</table>
<table>.....</table>
<table>.....</table>
How can I do to preserve the original order? Thanks!