<!DOCTYPE html>
<html>
<head>
<title>php</title>
</head>
<body>
<?php
$images_extensions = ['txt'];
$dir = 'text';
$f = array_slice(scandir($dir), 2);
foreach($f as $filename) {
$files = fopen($filename, 'r');
$filesname = fread($files, 10);
$file_extension = strtolower(substr($filename, strrpos($filename, '.')+1));
if (!in_array($file_extension, $images_extensions)) continue;
echo '<p>' . $filesname .'</p>';
}
?>
</body>
</html>
выводи ошибку
Warning: fopen(ege.txt): failed to open stream: No such file or directory in C:\xampp\htdocs\test\index.php on line 13
Warning: fread() expects parameter 1 to be resource, bool given in C:\xampp\htdocs\test\index.php on line 14
Warning: fopen(text.txt): failed to open stream: No such file or directory in C:\xampp\htdocs\test\index.php on line 13
Warning: fread() expects parameter 1 to be resource, bool given in C:\xampp\htdocs\test\index.php on line 14