Re: foreach statement

From: Date: Wed, 26 Mar 2003 00:15:52 +0000
Subject: Re: foreach statement
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-141040@lists.php.net to get a copy of this message
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" <goodie@apollointeractive.com> To: "shaun" <shaun@mania.plus.com>; <php-general@lists.php.net> 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:shaun@mania.plus.com] > Sent: Tuesday, March 25, 2003 3:23 PM > To: php-general@lists.php.net > 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 > >

« previous php.general (#141040) next »