PHP Arrays and Loops

Video loading...

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:07
    LEANNA PELHAM: We've seen how we can create variables
  • 0:09
    and set each to a string or a number.
  • 0:12
    We've also used functions like Rand and strtoupper
  • 0:15
    to return numbers and strings.
  • 0:17
    Let's talk about a third type of variable in PHP, an array.
  • 0:21
    An array represents a group of things,
  • 0:23
    like five random numbers or three strings.
  • 0:26
    They're a really important type of data in PHP, and in a few minutes
  • 0:30
    you'll know all about them.
  • 0:33
    To understand arrays, first imagine that there
Loading ...

PHP Arrays and Loops

Loading...

We've seen how we can create variables and set each to a string or a number. We've also used functions like rand and strtoupper to return numbers and strings. Let's talk about a third type of variable in PHP: an array. An array represents a group of things, like 5 random numbers or 3 strings. They're a really important type of data in PHP, and you'll be using them often. In this lesson we'll create an array, and then use foreach to loop through the array so we can complete a repetitive action for each item in the array. We'll also look at how you can access a specific item in an array, explaining keys and indexes.

Downloads: 
Log in or sign up to download companion files.
Additional resources: