Re: Surpressing a 'foreach' Error Message
| From: | John W. Holmes | Date: | Sat, 07 Feb 2004 23:19:59 +0000 |
| Subject: | Re: Surpressing a 'foreach' Error Message | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-177064@lists.php.net to get a copy of this message | ||
craig wrote:
craig <mailto:php@lonsbury.com>You'll still get the notice message with is_array(), though. Use isset(). if(isset($project)) or if(isset($project) && is_array($project)) -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.comon Friday, February 06, 2004 2:24 PM said:my bad, that's what you get when you don't actually run the code. Thank god for compilers ;)if (is_array($project)) foreach ($project as $project_id => $value) { $fields[] = $project_id; $values[] = $value; } }you're missing a curly brace after the if ().