Learn PHP Array through easy tutorial

 

How to print array in PHP

An array stores multiple values in one single variable:

<?php
$fruits = array("apple", "banana", "orange");
echo "I like " . $fruits[0] . ", " . $fruits[1] . " and " . $fruits[2] . ".";
?>

 

An array print through looping:

<?php
$fruits = array("apple", "banana", "orange");

foreach($fruits as $value) {
    echo $value;
}
?>