I have a text file with 3 sentences from a URL, two sentences are present. No matter what i do, this code always just shows the last variable from the textfile. It looks exactly as what we need, but we need it forevery word/sentence.
Played for hours, cannot get it to work. Who can point me in the right direction?
[php]
$url = "http://www.".$_GET['u']; //"example.com/";
$lines = file("all_claims.txt");
include_once('simple_html_dom.php');
function scraping_for_text($iUrl,$iText)
{
// create HTML DOM
$html = file_get_html($iUrl);
// get text elements
$aObj = $html->find('text');
foreach ($aObj as $key=>$seString)
{
$plaintext = $seString->plaintext;
if (stripos($plaintext,$iText) !== FALSE)
{
echo "<b>".$iText."</b><br />";
echo $key.": text=".$plaintext."<br />"
."--- parent tag=".$seString->parent()->tag."<br />";
}
}
// clean up memory
$html->clear();
unset($html);
return;
}
ini_set('user_agent', 'My-Application/2.5');
foreach($lines as $line)
{
echo $line."<br />";
scraping_for_text($url,$line);
}
[/php]
I would really appreciate the help.
KK.