PHP Array

In this chapter you will learn:

  1. What is a PHP Array
  2. Two types of arrays

Description

An array is a normal PHP variable, but we can put other variables inside it. Each variable inside an array is called an element. Each element has a key and a value, which can be any other variable.

Two types of arrays

PHP supports two types of arrays:

  • Indexed arrays - where each element is referenced by a numeric index, usually starting from zero. For example, the first element has an index of 0, the second has an index of 1, and so on
  • Associative arrays (hash or map) - each element is referenced by a string index.

Next chapter...

What you will learn in the next chapter:

  1. What is Indexed Array and how to create Indexed Array
  2. Create a PHP array
  3. Example to create PHP Array
  4. Array interpolation
Home » PHP Tutorial » PHP Array
PHP Array
PHP Create Indexed Array
PHP Create Associative Arrays
PHP Array Operator
PHP Access Array Element
PHP Change Array Element
PHP Create Array using Square Bracket
PHP Array Element Loop Through
PHP Array foreach loop
PHP Change Array Values with foreach
PHP Array Multidimensional
PHP Access Element in Multidimensional Array
PHP Loop Through Multidimensional Array