|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2000-07-31 22:41 UTC] waldschrott@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 08:00:01 2025 UTC |
Given the following code: unset($list); foreach($list as $value) { print($value); } and $list is FALSE, PHP is generating an error like "Non array argument supplied for foreach()". The variable probably should be promoted to being an empty array, but I can deal with casting it myself. Unfortunately, when I do this: unset($list); foreach((array)$list as $value) { print($value); } it runs through the loop once. I know I can get around this using a while loop, but I'd prefer to use foreach. If anyone's wondering why the hell I'm looping over an unset variable, I have a caching function that returns the contents of a database table. When there are no rows, it returns the unset static variable.