Arrays in PHP

phpArrays are nothing more than an integer-indexed collection of items.  An index of an array always starts from 0.  The collection of items in an array could be of any data type like string, int, float or even an another array which forms a nested array.  The length of an array is not fixed because you always have the ability to add more items to it.  Example of an array is given below.

<?php
    
    $array= array("Robert", "Andrea", "Sam", "Peter", "Rony" );

    //Printing array items.
    echo print_r($array). "<br />" ;

    //Printing 5 item in array.
    echo $array[4]. "<br />" ;


    //Adding an item to array.
    $array[] = "Mary";

     //Printing array items.
    echo print_r($array). "<br />" ;

    //Printing 6 item in array.
    echo $array[5]. "<br />" ;
    
?>