PHP preg_grep not working? I'm PHP beginner, and English communication also. The execution result of this program is indicated by "ArrayArray"...
<?php
$news = fopen("news.txt", "r"); 
$keywords = fopen("keywords.txt", "r"); 
$open_news = [];
while (!feof($news)) {
    $open_news[] = fgets($news);
}
$arr_keywords = [];
while (!feof($keywords)) {
    $arr_keywords[] = fgets($keywords);
}
$count = count($arr_keywords); 
for ($i = 0 ; $i <= $count; $i++) {
    if ($x = preg_grep("/^" . $arr_keywords[$i]  . "/", $open_news)) {
        echo $x;
        }
}
fclose($news); 
fclose($keywords); 
?>
 
                        
preg_grep returns array of matched lines, so you should rewrite your code to
A whole script can be simplified: