Re: [PHP] foreach statement

2003-03-25 Thread Jim Lucas
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



RE: [PHP] foreach statement

2003-03-25 Thread Jennifer Goodie
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



Re: [PHP] foreach statement

2003-03-25 Thread Richard Whitney
Get rid of the error

Quoting shaun <[EMAIL PROTECTED]>:

### 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
### 
### 


-- 
Richard Whitney   *
Transcend Development
Producing the next phase of your internet presence.
[EMAIL PROTECTED]   *
http://xend.net*
602-971-2791
  * *   *
*  *  *__**
 _/  \___  *
 *  /   *\**
  */ * *  \
**/\_ |\
 /   \_  /  \
/  \/\
   /  \ 
  /\
 /  \


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] foreach statement

2003-03-25 Thread shaun
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



RE: [PHP] foreach statement

2002-01-09 Thread Niklas Lampén

You're welcome. :)


Niklas


P.S. I know... ;)


-Original Message-
From: Chris Grigor [mailto:[EMAIL PROTECTED]] 
Sent: 9. tammikuuta 2002 10:23
To: '[EMAIL PROTECTED]'; Php-General
Subject: RE: [PHP] foreach statement 


Thanks!! its working !!! 

***BIG SMILE

Niklas you genious 



-Original Message-
From: Niklas Lampén [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 09, 2002 10:15 AM
To: Php-General
Subject: RE: [PHP] foreach statement 


Foreach works in PHP just like I told.

foreach($emails as $this_is_one_address) is the correct form where
$emails is an array and $this_is_one_address gets one element from
$emails.

This is similar to this (technically):

for ($i = 0; $i < count($emails); ++$i)
{
$this_is_one_address = $emails[$i];
// Do anything you want with $this_is_one_address
};

I suggest that you use the for-loop if $emails array is big. Takes less
memory.


Niklas



-Original Message-
From: Chris Grigor [mailto:[EMAIL PROTECTED]] 
Sent: 9. tammikuuta 2002 9:44
To: '[EMAIL PROTECTED]'; Php-General
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 ?

?





mailto:[EMAIL PROTECTED]] 
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




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: [EMAIL PROTECTED]


--
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] foreach statement

2002-01-09 Thread Chris Grigor

Thanks!! its working !!! 

***BIG SMILE

Niklas you genious 



-Original Message-
From: Niklas Lampén [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 09, 2002 10:15 AM
To: Php-General
Subject: RE: [PHP] foreach statement 


Foreach works in PHP just like I told.

foreach($emails as $this_is_one_address) is the correct form where
$emails is an array and $this_is_one_address gets one element from
$emails.

This is similar to this (technically):

for ($i = 0; $i < count($emails); ++$i)
{
$this_is_one_address = $emails[$i];
// Do anything you want with $this_is_one_address
};

I suggest that you use the for-loop if $emails array is big. Takes less
memory.


Niklas



-Original Message-
From: Chris Grigor [mailto:[EMAIL PROTECTED]] 
Sent: 9. tammikuuta 2002 9:44
To: '[EMAIL PROTECTED]'; Php-General
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 ?

?





mailto:[EMAIL PROTECTED]] 
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




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: [EMAIL PROTECTED]


--
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] foreach statement

2002-01-09 Thread Niklas Lampén

Foreach works in PHP just like I told.

foreach($emails as $this_is_one_address) is the correct form where
$emails is an array and $this_is_one_address gets one element from
$emails.

This is similar to this (technically):

for ($i = 0; $i < count($emails); ++$i)
{
$this_is_one_address = $emails[$i];
// Do anything you want with $this_is_one_address
};

I suggest that you use the for-loop if $emails array is big. Takes less
memory.


Niklas



-Original Message-
From: Chris Grigor [mailto:[EMAIL PROTECTED]] 
Sent: 9. tammikuuta 2002 9:44
To: '[EMAIL PROTECTED]'; Php-General
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 ?

?





mailto:[EMAIL PROTECTED]] 
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




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: [EMAIL PROTECTED]


--
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] foreach statement

2002-01-08 Thread David Balatero

Nope, the exact syntax is 

foreach ($emails as $this_is_one_address) {

}

...With that "as" in there.

HTH
David Balatero
[EMAIL PROTECTED]

- Original Message - 
From: "Chris Grigor" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; "Php-General" <[EMAIL PROTECTED]>
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:[EMAIL PROTECTED]] 
> 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: [EMAIL PROTECTED]
> 
> 
> --
> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED] To
> contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] foreach statement

2002-01-08 Thread Chris Grigor

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 ?

?





mailto:[EMAIL PROTECTED]] 
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




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: [EMAIL PROTECTED]


--
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] foreach statement

2002-01-08 Thread Niklas Lampén

I think this is what you want to do:

mailto:[EMAIL PROTECTED]] 
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




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: [EMAIL PROTECTED]


--
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] foreach statement

2002-01-08 Thread Chris Grigor

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




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: [EMAIL PROTECTED]

--
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]