Arrays

    Creating Arrays

    $arr = array("Alabama","Alaska", ... );
    
    Or...
    $arr = array(1=>"Alabama",2=>"Alaska", ... );
    

    Iteration:

    Array length - count($arr)
    for($i=0; $i<count($arr); $i++) {
      echo "Element:$i - Value:$arr[$i]";
    }
    

    Other array functions:

    • array_push() - Adds an element to the array
    • array_pop() - takes off last array entry
    • implode() - concatenates array elements
      $imp = implode(":",$array);
    • explode() - creates an array out of a delimited string
      $exp = explode(":",$string);
    • sort() - sorts an array
    • rsort() - reverse sorts an array
    • NEXT
      PREVIOUS
      Master Index