i have a code for searching words from other web page but it dont work and echo “bool(false) bool(false) bool(false) bool(false)”
i dont know whats problem
setlocale(LC_ALL, "en_US.utf8");
$keywords = array("REVUELE","word2","word3","word4");
$doc = file_get_contents("https://takashop.ir/blog/c-%DA%A9%D8%B1%D9%85%D9%87%D8%A7");
$doc = strtolower($doc);
$doc = preg_replace('!/*.*?*/!s', '', $doc);
$doc = preg_replace("/<!--.*>/i", "", $doc);
$doc = preg_replace('!<script.*?script>!s', '', $doc);
$doc = preg_replace('!<style.*?style>!s', '', $doc);
$doc = strip_tags($doc);
$doc = preg_replace('/[^0-9a-zs]/','',$doc);
$doc = iconv('UTF-8', 'ASCII//TRANSLIT', $doc); // check if encoding is really utf8
//$doc = preg_replace('{(.)1+}','$1',$doc); remove duplicate chars ... possible step to add even more fuzzyness
$doc = preg_split("/s+/",trim($doc));
foreach($keywords as $word) {
$word = strtolower($word);
$word = iconv('UTF-8', 'ASCII//TRANSLIT', $word);
$key = array_search($word,$doc);
var_dump($key);
if($key !== false) {
echo "match: ";
for($i=$key;$i<=5 && isset($doc[$i]);$i++) {
echo $doc[$i]." ";
}
}
}