Re: foreach statement

From: Date: Wed, 09 Jan 2002 08:02:10 +0000
Subject: Re: foreach statement
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-79877@lists.php.net to get a copy of this message
Nope, the exact syntax is foreach ($emails as $this_is_one_address) { } ...With that "as" in there. HTH David Balatero david.balatero@attbi.com ----- Original Message ----- From: "Chris Grigor" <CGrigor@mweb.com> To: <niklas.lists@publico.fi>; "Php-General" <php-general@lists.php.net> Sent: Tuesday, January 08, 2002 11.44 PM Subject: RE: [PHP] foreach statement > Hey Niklas > > yea thats what I want, just one thing > > foreach($emails as $this_is_one_address) { > > would it be > > foreach($emails) { > > or am I missing something in there ? > > ????? > > > > > > <? > $sms_list = "test_number"; // This is the file with one e-mail address > per line? > $emails = file($sms_list); > > foreach($emails as $this_is_one_address) { > // Do what ever you want to. > // $this_is_one_address contains one element from $emails > }; > > > Niklas > > > > -----Original Message----- > From: Chris Grigor [mailto:CGrigor@mweb.com] > Sent: 9. tammikuuta 2002 8:59 > To: 'Php-General-List (E-mail)' > Subject: [PHP] foreach statement > > > Okay lets see who has there thinking caps on today (cos I really dont) > > I have a list of email addresses stored in a text file. > > I am able to run the script and get all the mail addresses in the list > mailed but > thats all in one mail. I want to be able to open the file, chop each > line and send > individual messages to each address.. okay who is confused as Im not > giving you much > description here, well okay heres what the script looks like.... > > #!/usr/bin/php -q > > <? > > > $sms_list = "test_number"; > $emails = file($sms_list); > > for ($i=0; $i < count($emails); $i++) $emails[$i] = > trim($emails[$i]); > $recipient = implode(",", $emails); > > print "$recipient"; > > > { > > $mail_subject="test this"; > $mail_body="testing"; > mail($recipient, $mail_subject, $mail_body); > print "mail sent\n"; > > } > > > ?> > > > Im just thinking(trying to at least) I need some sort of foreach > statement like in perl, right? > so that it would say > > foreach($recipient) > { > send mail > } > > > anyone that could maybe guide me? > > Thanks in advance > > C-Ya > > Chris Grigor > ------------------------------------------------------------------------ > ---- > -------------- > Client Services > Call Center: 0860 100 154 > Fax: +27 11 340 7345 > E-Mail: Support@Bus-Sol.co.za > ------------------------------------------------------------------------ > ---- > -------------- > M-WEB Business Solutions > Making it happen. > > Go shopping @ http://shopping.mweb.co.za > Get your business online @ http://business.mweb.com > > "We all know Linux is great...it does infinite loops in 5 seconds." > - Linus Torvalds > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net To > contact the list administrators, e-mail: php-list-admin@lists.php.net > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#79877) next »