Skip to content

Instantly share code, notes, and snippets.

@lizettepreiss
Last active July 3, 2016 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lizettepreiss/af856e62e32027cbc5eccdcaebabfcde to your computer and use it in GitHub Desktop.
Save lizettepreiss/af856e62e32027cbc5eccdcaebabfcde to your computer and use it in GitHub Desktop.
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