Hey there,
This is one way to extract the contents between html tags (not nested). I hope this helps 🙂
<!--temp0001.dat data-->
<table>
<tr>
<td>
<!--DATA001TOOBTAIN-->
This is line 1 of 4 of text in a table cell document.
<!--DATA001TOOBTAIN-->
</td>
<td>This is line 2 of 4 of text in a table cell document.</td>
<td>This is line 3 of 4 of text in a table cell document.</td>
<td>This is line 4 of 4 of text in a table cell document.</td>
</tr>
</table>
<!--temp0001.dat data-->
function extractHTMLContents($filename, $tag) {
$filecontents = file_get_contents($filename);
$endtag = str_replace("<", "</", $tag);
$extractedtext = array();
while(($pos = strpos($filecontents, $tag, 0))) {
$contents = substr($filecontents, $pos, strlen($filecontents));
$pos01 = strpos($contents,$tag,0);
$pos02 = strpos($contents,$endtag,0);
$length = $pos02 - $pos01 - strlen($tag);
$pos01 += strlen($tag);
$text = substr($contents,$pos01,$length);
$extractedtext[] = trim($text);
//the rest of the contents
$filecontents = substr($contents, strpos($contents, $endtag,0), strlen($contents));
}
return $extractedtext;
}
use:
<?php
return extractHTMLContents("temp0001.dat", "<td>");
?>
kent