• Archives

  • AddThis Social Bookmark Button

    Add to Technorati Favorites

  • Upcoming Conferences

    • no upcoming events
  • Using for each to loop through an array

    By krates | December 16, 2007

    Sometimes you need to loop through an for this the for each function is used for example.

    $grade = array(“first_name” => “First Name”,
    “middle_name” => “Middle Name”,
    “last_name” => “Last Name”,
    “phone” => “Phone”);

    foreach($grade as $field => $gard)
    {
    echo ”
    $gard The name of the array $field

    “;
    }
    ?>

    Notice the variable $grade arrays starting from first_name is given to $field and then the array value is given to label

    U can use this in many forms

    Thanks
    krates

    Share and Enjoy:
    • Digg
    • del.icio.us
    • Facebook
    • NewsVine
    • Reddit
    • StumbleUpon
    • YahooMyWeb
    • Google Bookmarks
    • Yahoo! Buzz
    • TwitThis
    • Live
    • LinkedIn
    • Pownce
    • MySpace

    Topics: PHP | Comments Off

    Related Links:

    Comments are closed.