Return to Snippet

Revision: 59459
at September 9, 2012 21:37 by ashmenon


Initial Code
<?php

$variable_name = array();  //Create a blank array, or empties an array.

$variable_name[] = 'valueA';  //Add a value to the array. If you do this again, it will add a second value to it, not replace the first one.
array_push($variable_name,'valueB'); //Another way to add a value to an array.

echo count($variable_name); //Displays the number of values in the array. This will input 2, because we added valueA and valueB to the array.

sort($variable_name); //Sorts the values within an array. There are several types of sorting, each with their own options. 

?>

Initial URL

                                

Initial Description
Beginner PHP Chapter 5 - Arrays

Initial Title
Beginner PHP Chapter 5 - Arrays - Code Block 2

Initial Tags

                                

Initial Language
PHP