Reputation: 1554
I tring to check if a folder is empty but I keep getting this error
Warning: file_exists() expects parameter 1 to be string, array given
if(!file_exists(glob('/upload/'.$id.'/temp/*'))){
$smeg = 'empty';
}
Upvotes: 0
Views: 4922
Reputation: 68526
glob
returns an array
type.
Change your code like this
foreach(glob('/upload/'.$id.'/temp/*') as $filename)
{
if(!file_exists($filename))
{
$smeg = 'empty';
}
}
Upvotes: 2
Reputation: 5899
From the PHP doc about glob()
:
Returns an array containing the matched files/directories, an empty array if no file matched or FALSE on error.
You have to loop over the result
foreach(glob('/upload/'.$id.'/temp/*') as $file) {
if(!file_exists($file)){
$smeg = 'empty';
}
}
Upvotes: 2