RE: [PHP] next,key,current question
| From: | Chris Hubbard | Date: | Thu, 13 Nov 2003 20:16:09 +0000 |
| Subject: | RE: [PHP] next,key,current question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-169557@lists.php.net to get a copy of this message | ||
Sara,
Try this:
$count = count ($Classes);
for($i=0; $i<$count; $i++){
$CurrentIndexValue = key($Classes);
$CurrentContents = current($Classes);
echo "<option
value='$CurrentIndexValue'>$CurrentContents</option>";
next($Classes);
}
instead of the for loop you're using.
currently you're doing a next first, which will move you to the next element
in the array.
And then you're echoing the variables from the while loop, you should be
using the variables you've got in the for loop.
chris
-----Original Message-----
From: Sara Daugherty [mailto:sara@areawebdirectory.net]
Sent: Thursday, November 13, 2003 3:02 PM
To: php-general@lists.php.net
Subject: [PHP] next,key,current question
I am having trouble with creating a list box.
I am attaching the code.
I am not sure the code in the for loop close to the end of the program
is correct.
If someone could take a look at it I would appreciate it.
Thanks,
Sara