Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHP Array Basics 1
<?php
//Assign automatically
$cars = array("Volvo", "BMW", "Toyota");
//or assign manually
$cars[0] = "Volvo";
$cars[1] = "BMW";
$cars[2] = "Toyota";
echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";
//Array Length
echo count($cars);
// Loop through array
$arrlength = count($cars);
for($x = 0; $x < $arrlength; $x++) {
echo $cars[$x];
echo "<br>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.