Jump to content

PHP Array Output...


QueenZ

Recommended Posts

Hi guys! I don't know why but this php code outputs me the array wrong...

 

<?php
$options = array
(
    01 => 'adam',
    02 => 'betty',
    03 => 'charles',
    04 => 'denise',
    05 => 'eric',
    06 => 'adam',
    07 => 'betty',
    08 => 'charles',
    09 => 'denise',
    10 => 'eric'
);

foreach ($options as $index => $value)
{
echo $index . "<br>";
}
?>

 

It outputs...

 

1

2

3

4

5

6

7

0

10

 

But why?? What does it mean?? First of all there are 9 numbers not 10 and second of all it shows 0 after 7 not 8 and 9 is missing as well..? What have i made wrong?? Please help!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.