From 91cf805ecfcf08573b3aee98453e97f5fe923a98 Mon Sep 17 00:00:00 2001 From: "Jeremy S. Johnstone" Date: Sun, 2 Nov 2003 15:56:41 +0000 Subject: [PATCH] Cleaned up example. Switched it to using foreach instead of while/list/each. Also added extra sanity check as suggested in the notes (count($address_array) < 1). git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@143606 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/imap/functions/imap-rfc822-parse-adrlist.xml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/reference/imap/functions/imap-rfc822-parse-adrlist.xml b/reference/imap/functions/imap-rfc822-parse-adrlist.xml index 6e925e3dc2..71efc0bced 100644 --- a/reference/imap/functions/imap-rfc822-parse-adrlist.xml +++ b/reference/imap/functions/imap-rfc822-parse-adrlist.xml @@ -1,5 +1,5 @@ - + @@ -51,10 +51,9 @@ , postmaster@somedomain.net, root"; $address_array = imap_rfc822_parse_adrlist($address_string,"somedomain.net"); -if(! is_array($address_array)) die("somethings wrong\n"); +if(!is_array($address_array) || count($address_array) < 1) die("something is wrong\n"); -reset($address_array); -while(list($key,$val)=each($address_array)){ +foreach($address_array as $val) { print "mailbox : ".$val->mailbox."
\n"; print "host : ".$val->host."
\n"; print "personal: ".$val->personal."
\n";