Last active
July 3, 2016 09:30
-
-
Save lizettepreiss/af856e62e32027cbc5eccdcaebabfcde to your computer and use it in GitHub Desktop.
PHP Array Basics 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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