Re: accessing array value in for loop
A "Web page" location wouldn't help anyways, but to be sure it is understood. If in the exact place where you have the for loop, you instead assign the $email_array such that $email_array[0] has data, then it works the rest of the way through?
Do you do an assignment to $email_array to declare it before the for loop? Like:
Code:
$email_array = array();
If the assignment of $email_array[0] related data is happening just before the processing of the email, then of course it will operate. The situation here is better "explained" by providing the code through which all this is processed or identifying things like where a function "group" exists if any, or that no function block exists between the two. Or, and going out on a limb, just before the email generation loop, like the line before, if you add global $email_array; might it fix the issue?
Re: accessing array value in for loop
Quote:
Originally Posted by
jeffiec
So the problem is that i cant access the 2 variables in the loop.
If I echo $email_array[0]['email'] with the index hardcoded, it will give me the result [email protected], but the minute i put put in a variable for the index, $email_array[$x]['email'], the result is empty.
Did you echo $x too? What you describe sounds like $x is something unexpected.
And what about $snd_cnt ?
Re: accessing array value in for loop
Quote:
Originally Posted by
DrByte
Did you echo $x too? What you describe sounds like $x is something unexpected.
And what about $snd_cnt ?
Yes, i echo'd them both, $x is empty, while $snd_cnt has the expected value.
I haven't tried adding the global yet, will try that tomorrow and let you know if it solves it.
Re: accessing array value in for loop
Quote:
Originally Posted by
jeffiec
Yes, i echo'd them both, $x is empty, while $snd_cnt has the expected value.
I haven't tried adding the global yet, will try that tomorrow and let you know if it solves it.
If $x is empty then you've got even bigger problems, assuming you're echoing $x from inside the "for ($x=0; ...$x++)" loop.
Re: accessing array value in for loop
Possibly the variable $x is getting clobbered somewhere else, if you're only showing part of your code? Maybe don't use array indexes - try this instead:
Code:
foreach ($email_array as $email_addy) {
$send_to_name = $email_addy['name'];
$send_to_email = $email_addy['email'];
...
}
Re: accessing array value in for loop
It seems to be going through the loop as i get errors that it cant send to "" blank field the correct number of times.
I still haven't gotten around to trying to use $global yet. I have another issue i am making a post about before i can get back on this issue lol.
Re: accessing array value in for loop
Well ended up rewriting the page and it works now, must have been some loose code somewhere, mark this resolved.
Thanks a ton
Jeff