Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: each()

  1. #1
    Regular Coder
    Join Date
    Jan 2008
    Posts
    334
    Thanks
    9
    Thanked 0 Times in 0 Posts

    each()

    Hello everyone!

    Just a quick question. I was just wondering if you guys could me a better idea on what the each() does. Give me a idea how this is used and how it comes to use. I understand what it suppose to do kinda, but I just don't get how it can come to use.

    Thanks
    Jon W

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Each is used as a means to seperate individual values from an array:
    PHP Code:
    $myArr = array ('I''AM''AN''ARRAY');
    list (
    $v1$v2$v3$v4) = each($myArr); 
    The $v* variables now contain each item of the myArr. Not really useful IMO, its almost like a 'cheap' way of getting around unset variable problems if no corresponding data exists. Strangely enough, it is not a part of the iteration aggregates, and not normally used in object traversal. Kinda odd IMO, it would probably help a lot with object control.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • Users who have thanked Fou-Lu for this post:

    Jon W (01-14-2008)

  • #3
    Regular Coder
    Join Date
    Jan 2008
    Posts
    334
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Fou-Lu,

    Thanks for your reply. It was truely helpful.


    Jon W.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •