i have this little function that I wrote to do just that. function alternate(&$a, $b) { return($a = ($a?$a:$b) ); }
just call it like this alternate($myArr, array()); foreach($myArr AS $k => $v) { do something here } Jim ----- Original Message ----- From: "Jennifer Goodie" <[EMAIL PROTECTED]> To: "shaun" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Tuesday, March 25, 2003 3:34 PM Subject: RE: [PHP] foreach statement > You don't. > From http://www.php.net/manual/en/control-structures.foreach.php > "Note: foreach does not support the ability to suppress error messages using > '@'." > > You should check the validity of your argument before passing it to foreach > > if(is_array($array)){ > foreach($array as $key=>$val){ > //do stuff > } > } > > -----Original Message----- > From: shaun [mailto:[EMAIL PROTECTED] > Sent: Tuesday, March 25, 2003 3:23 PM > To: [EMAIL PROTECTED] > Subject: [PHP] foreach statement > > > how do i surpress an error message for a foreach statement? > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php