note 48287 added to function.glob

From: Date: Fri, 17 Dec 2004 20:27:07 +0000
Subject: note 48287 added to function.glob
Groups: php.notes 
Request: Send a blank email to php-notes+get-81943@lists.php.net to get a copy of this message
I noticed that when I foreach (glob ( etc. I get a warning: "Invalid argument supplied for foreach()". This is obviously not fatal and the code will work, but for a testing server it's irritating having to sift through meaningless warnings (it's also irritating if you end up with warnings reported on a production server, ug). My quick and dirty solution: foreach (($result_set = glob ("????") ? $result_set : array ("empty_filename")) as $filename) { if ($filename = "empty_filename") echo "No four-letter file"; } Hope this helps someone that's as irritated as I was. ---- Manual Page -- http://www.php.net/manual/en/function.glob.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+48287 Delete -- http://master.php.net/manage/user-notes.php?action=delete+48287&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48287&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48287&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48287&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48287&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48287&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+48287&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#81943) next »