PHP Arrays

One of the most important things to learn in PHP is - how to create and work with arrays. It's so useful that once you figure it out for yourself, you'll be glad you did! Everything I do in PHP involves an array or two - that's how important it is to me.

What is an array

The simplest way to explain what an array is, is to show you the difference between an array and a regular variable in PHP:

In PHP a variable stores a value, like so:

php:


<?php
  $name = 'Garth Farley';
?>


In PHP an array stores a set of values, like in the following example:

php:


<?php
  $name = array( 'Garth Farley','Andrew Duffell','Scott Deming' );
?>


There are 3 types of arrays:

  1. Numerically Indexed Arrays
  2. Associative Arrays
  3. Multidimensional Arrays

TOP

Do you like the new design?

 Yes

 No

 Don't know