PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 29th, 1999, 11:42 AM
tmak
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:

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


Reply With Quote
  #2  
Old December 29th, 1999, 06:07 PM
rod k
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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";
}

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Array Help...

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap