I have this php code
$files_array = array();
$files_array = glob('*.aria2');
$files_array = str_replace('.aria2', '', $files_array);
array_push($files_array,"processing");
If i print result of $files_array
Array
(
[0] => [LiveFish] Vanguard [AAC]
[1] => [Riycou] K-Project [MP4 AAC 720p]
[2] => processing
)
I use in_array code
if(!in_array($ff, $files_array))
{
listFolderFiles($dir.'/'.$ff);
}
Php return me an error
PHP Warning: in_array() expects parameter 2 to be array, null given
My $files_array variable seems okay, if I use print_r, it was able to display the array value, why would php give me an error mention parameter 2 was null
Below is my full code structure
$files_array = array();
$files_array = glob('*.aria2');
$files_array = str_replace('.aria2', '', $files_array);
array_push($files_array,"processing");
print_r($files_array);
function listFolderFiles($dir){
$ffs = scandir($dir);
$i = 0;
$list = array();
foreach ( $ffs as $ff ){
if ( $ff != '.' && $ff != '..' ){
if ( strlen($ff)>=5 ) {
$extension = array('.mkv', '.avi', '.mp4');
$file_extension = substr($ff, -4);
if ( in_array($file_extension,$extension )) {
$list[] = $ff;
echo dirname($ff) . $ff . "<br/>";
$fileName = $dir.'/'.$ff;
}
}
if( is_dir($dir.'/'.$ff) )
if(!in_array($ff, $files_array)) {
listFolderFiles($dir.'/'.$ff);
}
}
}
return $list;
}