In general the arrays are variables capable of storing more than one value.  

The arrays in PHP are similar to arrays in other language, that is they can store multiple strings and other data types in one variable; also if a regular variable is capable of storing one sentence, an array can store more than one sentence depending on the size of the array. 

The syntax below is showing hot to create a basic PHP array:

Syntax for creating PHP array

<?php
    $array = array ("element / variable #1", "element / variable #2", ... "element / variable #n");
?>

Some of the basic array handling functions are mentioned below.

Multidimensional arrays

A multidimensional array is an array that contains other arrays (multiple arrays) nested within itself.

Example of a multidimensional array 

$multi_array = array
    (
    array ("name", "age", "title"),
    array ("Judy", "66", "retired"),
    array ("Robert", "56", "IT")
    );

The is_array () function

The is_array(variable) function is used to check if a variable is an array or not and returns TRUE if it is.

Example with is_array() array function

The count() function

The count() function is used to count the elements in an array.

Example with count() array function

The unset() function

The unset() function may be used to remove the value of an array at a specified location. Note that the first element of the array will be removed but it will not change the index of the location.

Example with unset() value of an array function

 

›› go to examples ››