php - I want to compare values from one array with values of another array -


after search, script riches folder , read each individual file
, if found h1 put each word of in array $h1words
problem is, want compare 2 arrays $words , $h1words
, if there 1 similar character, show h1

if (isset($_get["sub"]) && $_get["sub"]=="search"){      // open known directory, , proceed read contents     $dir="c1/cat1/";     $words=explode(" ",$_get["search"]);     if (is_dir($dir)) {         if ($dh = opendir($dir)) {             while (($file = readdir($dh)) !== false) {                 if ($file=="" or $file=="." or $file==".." or $file=="index.php" or $file=="index.html") {                     continue;                 }                  $filet=$dir.$file;                 if (is_readable($filet)){                     $filee=fopen($filet,"r");                     while(!feof($filee)){                         $str=strip_tags(fgets($filee),"<h1>");                         $findme="<h1>";                         $pos = strpos($str, $findme);                         if ($pos!==false){                             $h1words=explode(" ",$str);                         }else{}                      }             echo "<br /><hr /><br />";             fclose($filee);                 }              }             closedir($dh);          }     } } 

loop through first array , compare each value each value of second array:

$i = 0 foreach($words $array1){   foreach($h1words $array2){     if($array1 === $array2){       //equal     }else{       //not equal     }   }   $i++ } 

this loop through each value in $words , compare each value in $h1words.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -