How to use array in PHP?

Example how to use array in PHP store multiple values in one single variable.

How use array in PHP


<?php
$month  = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
echo 'First month on year is  '.$month[0].', next  '.$month[1].' and so on. ';
?>
output: First month on year is  January, next  February and so on.

How to use count array?

It's really simple. Use count() php function.


<?php
$month  = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
echo count($month[0]);
?>
output: 12