page 1.html // get contents from page 2.html
Expand|Select|Wrap|Line Numbers
- function get_tag($htmlelement,$attr, $value, $html)
- {
- $attr = preg_quote($attr);
- $value = preg_quote($value);
- if($attr!='' && $value!='')
- {
- $tag_regex = '/<'.$htmlelement.'[^>]*'.$attr.'="'.$value.'" width="100%">(.*?)<\\/'.$htmlelement.'>/si';
- $matchCount = preg_match($tag_regex,$html,$matches);
- if ($matchCount > 0)
- {
- echo("$matchCount matches found.\n");
- }
- else
- {
- echo("no records");
- }
- }
- }
- $htmlcontent = file_get_contents("http://page2.html/");
- $extract = get_tag("table","class", "tablemenu", $htmlcontent);
- echo $extract;
I would like to grab all of the tables from the page and display them on another one.
Expand|Select|Wrap|Line Numbers
- // more code
- <table width="100%" class="tablemenu">
- <tbody>
- <tr>
- <td>
- </td>
- </tr>
- </tbody>
- </table>
- <table width="100%" class="tablemenu">
- <tbody>
- <tr>
- <td>
- // some data
- </td>
- </tr>
- </tbody>
- </table>
- <table width="100%" class="tablemenu">
- <tbody>
- <tr>
- <td>
- // some data
- </td>
- </tr>
- </tbody>
- </table>
- <table width="100%" class="tablemenu">
- <tbody>
- <tr>
- <td>
- // some data
- </td>
- </tr>
- </tbody>
- </table>
- // more code