The php arrays stores multiple data which can later use in the echo statement.

Example

[php]<?php
$cars = array("Volvo", "BMW", "Toyota");
echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";
?>[/php]

In the above statement. We have mention the variable $cars and it has given the array values. We have total three cars values in the array. On the next line, we are asking php script to echo the result by using array value. Remember the array value begins from zero (0) and increase it from theirs. That’s the reason why we have mentioned the first array value $cars[0] in the echo statement and increment it from there.

The outcome will look like this

I like Volvo, BMW and Toyota.

Related Posts

Leave a Reply