PHP Arrays



An array is a variable that holds a group of values.

Arrays are usually meant to store a collection of related data elements, although this is not a necessity.

You access the individual elements by referring to their index position within the array. The position is either specificied numerically or by name.

$arr = array( key => value , ... )

  • key may be an integer or string
  • value may be any value

Example :
<?php
                  $arr = array("foo" => "bar", 12 => true);

                  echo $arr["foo"]; // bar
                  echo $arr[12];    // 1
?>


Comments