Enter your Sign-on user name and password.

Forgot password?
  • Follow us on:
Loading video...

Start Learning Now

Our free lessons will get you started (Flash® 10 required).
Get immediate access to our entire library.

Sign up for Educator.com

Features Overview

  • Get on-demand access to our complete library
  • Search and jump to exactly what you need to learn
  • Track your progress
  • Download practice and lesson files
  • *Ask questions and get answers from our community & instructors

Introduction to Conditional Loops

  • A while loop is a conditional control structure that executes a statement group repeatedly as long as its specified test condition remains TRUE .
  • A while loop’s test condition’s value is compared to TRUE before each execution of the loop’s statement group.
  • 'Looping over arrays' is a common programming function, and PHP provides several built-in functions for doing so. They work on the basis of an array cursor , which is a 'marker' for the 'current' array element:
    • current() – returns the value of the array element at the current array cursor position
    • key() – returns the key of the array element at the current array cursor position
    • next() – advances the array cursor by one
    • prev() – moves the array cursor back by one
    • reset() – sets the array cursor to the 1st element
    • end() – sets the array cursor to the last element
  • The list() construct and the each() function are also used to loop over arrays.
  • list() is used to assign values to multiple variables at a time from an indexed array.
  • each() returns key/value information for the current array element in an array and advances the array cursor by one. It returns FALSE if the end of the array is reached.
  • Unlike some programming languages, PHP does not have ‘block-level’ scope used with control structures.
  • Additional Resources:

Introduction to Conditional Loops

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

Computer Science: Introduction to PHP