Generally speaking, an array is a type of a matrix that stores multiple values in one variable. The PHP can generate one or multidimensional arrays.

An example of an array would be: 

<?php
    $cities = array("Paris", "Hong Kong", "Washington", "Dubai");
?>

An array represents an ordered map in PHP. A map is a type that associates value to keys and is optimized for several different users. The above mentioned array is an indexed array which has a variable “name” and contains four elements. 

The length of an array can be found with the function count ($array);

Associative arrays are those which use name key that you assign to them, for instance:

$age = array("Diana"=>"35", "Margarita"=>"24", "Linda"=>"43");

A simple example of an array data type

<?php
    $array = array(
        "fruit1" => "apple",
        "fruit2" => "peach",
    );
    // from PHP 5.4 forward
    $array = [
        "fruit1" => "apple",
        "fruit2" => "peach",
    ];
?>

 

To learn more about PHP arrays follow this link.

 

›› go to examples ››