Using the array() Construct to Preload an Array

chinmay.sahoo

New member
Often you start out knowing exactly which values you want placed in an array. PHP provides a shortcut for loading an array with a set of values.

//use array function to load up array
$binary = array("000", "001", "010", "011");

In this example, I create an array of the first four binary digits (starting at zero). The array keyword can assign a list of values to an array. Note that when you use this technique, the indices of the elements are created for you.
 
Back
Top