What is missing here for the result, but it’s not clear what. It produces an error in the string result [] = $ arr [$ i];
function search_dir($dir, $word){ $arr=(scandir($dir)); for ($i = 0; $i < count($arr); $i++) { $pos=strpos($arr[$i],$word); if($pos!==false){ $result[]=$arr[$i]; } }return $result; } print_r(search_dir(__DIR__,'name'));
$result = glob($dir.'/*'.$word.'*');- Stanislav