Hai
is there any command in the php which will search for a particular keyword in the txt file and if the a single instance of the word is found then it will display a message or else not..
Wiedmann wrote:Define "single instance of the word".
<?php
$url_feed='http://tech2.in.com/rssfeed/rss_topstuff.xml';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://validator.w3.org/feed/check.cgi?url=$url_feed");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
$output = curl_exec($ch);
$fh = fopen("out.txt", 'w');
fwrite($fh, $output);
$value='img alt="[Valid RSS]" title="Valid RSS" src="images/valid-rss.png" /> This is a valid RSS feed.';
$section = file_get_contents('./out.txt', NULL, NULL, 1256, 95);
/*echo $section;
$fh1=fopen("out_1.txt",'w');
fwrite($fh1, $section);
fclose($fh1);
var_dump($section);*/
fclose($fh);
curl_close($ch);?>
$count = explode($yourword, $yourstring);
if (count($count) == 2)
{
// the word $yourword is in $yourstring (just 1 word)
}
elseif (count($count) > 2)
{
// the word $yourword is in $yourstring (more than 1 word)
}
else
{
// the word $yourword is NOT in $yourstring
}
Stepke-DSL wrote:Try this:
- Code: Select all
$count = explode($yourword, $yourstring);
if (count($count) == 2)
{
// the word $yourword is in $yourstring (just 1 word)
}
elseif (count($count) > 2)
{
// the word $yourword is in $yourstring (more than 1 word)
}
else
{
// the word $yourword is NOT in $yourstring
}
Regards Stepke
<?php
$url_feed='http://tech2.in.com/rssfeed/rss_topstuff.xml';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://validator.w3.org/feed/check.cgi?url=$url_feed");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
$output = curl_exec($ch);
$fh = fopen("out.txt", 'w');
fwrite($fh, $output);
$value='img alt="[Valid RSS]" title="Valid RSS" src="images/valid-rss.png" /> This is a valid RSS feed.';
$section = file_get_contents('./out.txt', NULL, NULL, 1256, 95);
$count = explode($value, $section);
if (count($count) == 2)
{
echo "1";
}
elseif (count($count) > 2)
{
echo "2";
}
else
{
echo "3";
}
/*echo $section;
$fh1=fopen("out_1.txt",'w');
fwrite($fh1, $section);
fclose($fh1);
var_dump($section);*/
fclose($fh);
curl_close($ch);
/*if($value!=$section)
{
echo "oops";
}
else
{
echo "Done";
}*/
?>
- Code: Select all
$value='img alt="[Valid RSS]" title="Valid RSS" src="images/valid-rss.png" /> This is a valid RSS feed.';
the required single instance of word i require is $value,
which will scan the entire txt file and will check for the $value and if it is there then it should display ok
Wiedmann wrote:
- Code: Select all
$value='img alt="[Valid RSS]" title="Valid RSS" src="images/valid-rss.png" /> This is a valid RSS feed.';
the required single instance of word i require is $value,
It doesn't looks like $value is a (one) "word".
BTW:which will scan the entire txt file and will check for the $value and if it is there then it should display ok
But I don't think you have understand my answer to your last question, how to validate a rss and get the result.
Users browsing this forum: No registered users and 261 guests