7. (B) Write a PHP program to create one dimensional array.
<?php | |
$cars = array("Volvo", "BMW", "Toyota"); | |
echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . "."; | |
echo count($cars); | |
$arrlength = count($cars); | |
for($x = 0; $x < $arrlength; $x++) | |
{ | |
echo $cars[$x]; | |
echo "<br>"; | |
} | |
//Associative arrays | |
$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43"); | |
echo "Peter is " . $age['Peter'] . " years old."; | |
?> |
7. (B) Write a PHP program to create one dimensional array.
Reviewed by admin
on
December 24, 2019
Rating:
No comments: