----- Original Message -----
From: "Ben Joyce" <[EMAIL PROTECTED]>

> Yeah, I figured it out using that a minute or so ago... but I'm sure there
> should be another way of doing it by enumerating the array like this:
>
> for($i=0;$i < count($_POST); $i++)
> {
> print $_POST[$i];
> }

The reason it won't work is this:  each element in the $_POST array has a
key which is specified along with the arguments passed to the page.  Unless
one of those keys is 0 or '0' there just won't be a $_POST[0].  See this
extract from the PHP help file / manual:

$a = array( 'color' => 'red'
          , 'taste' => 'sweet'
          , 'shape' => 'round'
          , 'name'  => 'apple'
          ,            4        // key will be 0
          );

In the above example there is an $a["sweet"] but no $a[1]  (I have run it
and checked!).  There is only an $a[0] because 0 is the next default key to
be associated with any value assigned to the array.  If you create an array
like this:

$a = array(0 => 'Fred', 4 => 'Jim');

...there will be an $a[0] and $a[4] but no intervening $a[1] to $a[3]

Arrays in PHP are associative arrays - a sort of list of key/value pairs.
Unlike arrays in C or BASIC, they don't have a range var[0] to var[max]
unless you assign values without a key.  The only way to iterate through the
values is with foreach() or each()

Bj





____ � The WDVL Discussion List from WDVL.COM � ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] 
       Send Your Posts To: [EMAIL PROTECTED]
To change subscription settings to the wdvltalk digest version:
    http://wdvl.internet.com/WDVL/Forum/#sub

________________  http://www.wdvl.com  _______________________

You are currently subscribed to wdvltalk as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to