Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17
  1. #11
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default 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?
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  2. #12
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: accessing array value in for loop

    Quote Originally Posted by jeffiec View Post
    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 ?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #13
    Join Date
    Jun 2009
    Posts
    86
    Plugin Contributions
    0

    Default Re: accessing array value in for loop

    Quote Originally Posted by DrByte View Post
    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.

  4. #14
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: accessing array value in for loop

    Quote Originally Posted by jeffiec View Post
    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.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #15
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,681
    Plugin Contributions
    123

    Default 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'];  
    ...
    }
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  6. #16
    Join Date
    Jun 2009
    Posts
    86
    Plugin Contributions
    0

    Default 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.

  7. #17
    Join Date
    Jun 2009
    Posts
    86
    Plugin Contributions
    0

    Default 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

 

 
Page 2 of 2 FirstFirst 12

Similar Threads

  1. help... Warning: Cannot use a scalar value as an array in cart_upsell.php
    By jamie in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 12 Nov 2010, 12:15 AM
  2. Replies: 2
    Last Post: 10 Jun 2009, 12:24 PM
  3. Huh? Where did the value ARRAY come from?
    By dbr66 in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 3 Jun 2008, 02:39 AM
  4. Huh? Where did the value ARRAY come from?
    By dbr66 in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 30 May 2008, 07:18 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR