ID:               23453
 Updated by:       [EMAIL PROTECTED]
 Reported By:      gearond at cvc dot net
-Status:           Open
+Status:           Feedback
 Bug Type:         Documentation problem
 Operating System: internet site
 PHP Version:      4.3.2RC2
 New Comment:

This is actually referring to a situation as shown in example #3 at
php.net/list  You are not using an array, you are using plain
variables, so don't need to worry about it...

Not sure how this can be rewritten, how do you think this can be
solved?  All the examples demonstrate that your code in this report is
wrong.


Previous Comments:
------------------------------------------------------------------------

[2003-05-02 13:09:54] gearond at cvc dot net

Dennis Gearon írta:

> The documentation of each() says:
>
>     array each ( array array)
>     --------------------------
>     Returns the current key and value pair from the array array and
>     advances the array cursor. This pair is returned in a
>     four-element array, with the keys 0, 1, key, and value.
>     Elements 0 and key contain the key name of the array element,
>     and 1 and value contain the data.
> The documentation of list() says:
>     Warning
>     --------
>
>     list() assigns the values starting with the right-most
parameter.
>     If you are using plain variables, you don't have to worry about
this.
>     But if you are using arrays with indices you usually expect the
order
>     of the indices in the array the same you wrote in the list()
from
>     left to right; which it isn't. It's assigned in the reverse
order.
>
>
=============================================================================
> To me, that says that each will issue an array with the element [0]
containing the key of an array postion, and the element[1] containing
the value of an
> array position.
> And so, using list on the array generated by each should assign the
key to the
> rightmost variable in the list and the value to the next variable to
the right.
>
=============================================================================
>
>
> If you try this, it will print out opposite of what you expect. It
prints out
> the keys to the array '$keys', not the values.
>
>                $event_fields_arr = array(
>                    "event_id" =>"",
>                    "usr_name" =>"",
>                    "usr_email" =>"",
>                    "centennial_name" =>"",
>                    "event_name" =>"",
>                    "event_category" =>"",
>                    "event_link" =>"",
>                    "event_cost" =>"",
>                    "event_phone" =>"",
>                    "event_begin_day" =>"",
>                    "event_begin_month" =>"",
>                    "event_begin_year" =>"",
>                    "event_end_day" =>"",
>                    "event_end_month" =>"",
>                    "event_end_year" =>"",
>                    "event_sched" =>"",
>                    "event_desc" =>"",
>                    "event_addr" =>"",
>                    "event_city" =>"",
>                    "event_state" =>"",
>                    "event_zip" =>"",
>                    "company_name" =>"",
>                    "company_addr" =>"",
>                    "company_city" =>"",
>                    "company_state" =>"",
>                    "company_zip" =>""
>                );
>                $keys = array_keys( $event_fields_arr );
>                while( list ($val, $key) = each( $keys ) ){
>                    echo( $val . "<br>" );
>                }
>
>



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=23453&edit=1


-- 
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to