I am getting an “invalid argument” error with this code. Please help me fix it.
$sub1 = "sub1";
$sub2 = "sub2";
$td = "4";
foreach (glob("directory/".$sub1."/".$sub2."*.td".$td) as $filename) { //This is the line throwing the error
echo "$filename size " . filesize($filename) . "\n"; //This is right from php.net manual
}
It looks like you’re missing a slash:
Should be:
(If I’ve got a variable that’s storing a directory, I always add the slash on the end – it keeps things consistent, and means I don’t need to remember to cat a slash back on when I’m using it.)