Thread: Array Help...

    #1
  1. No Profile Picture
    tmak
    Guest
    Devshed Newbie (0 - 499 posts)

    Could someone please enlighten me?
    I am trying to display an associative array.
    The array has been created properly because
    the proper values are displayed with know
    keys. Why then does the following snip of
    code only display 1 array value when I know
    there are more?

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    reset($employee_select);
    do {
    list($value,$option) = each($employee_select);
    print "<option value="" . $value . "">" . $option . "</option>n";
    } while(next($employee_select));
    [/quote]

    Could anyone post a nice little example of
    how to do this correctly?

    Thanks!
    mAk

  2. #2
  3. No Profile Picture
    rod k
    Guest
    Devshed Newbie (0 - 499 posts)
    Well, I don't know why it's not working, but I do see a problem. each() and next() both advance the array pointer. If you only have two elements that would be why you have a problem.

    Instead of a do..while loop, just use a while.

    while (list($value,$option)=each($employee_select)
    {
    print "<option value="$value">$option"<option>n";
    }

Similar Threads

  1. sort: find duplicate string elements in array
    By sciencelife in forum Java Help
    Replies: 3
    Last Post: January 27th, 2004, 02:29 PM
  2. C++ programming help.
    By Programming1 in forum C Programming
    Replies: 1
    Last Post: January 20th, 2004, 11:47 AM
  3. another remove array values from an array
    By robee in forum PHP Development
    Replies: 6
    Last Post: November 20th, 2003, 01:09 AM
  4. multi dimensional arrays - Can't grasp how to?
    By Kaleina in forum PHP Development
    Replies: 17
    Last Post: November 5th, 2003, 04:18 PM
  5. problem with array
    By Geekoidxp in forum PHP Development
    Replies: 3
    Last Post: October 12th, 2003, 02:22 PM

IMN logo majestic logo threadwatch logo seochat tools logo