Array Functions



Prev. Page
Index Page
Next Page

  • There are four functions for adding elements to and removing elements from arrays:
    array_shift()   removes an item from the beginning of an array
    array_unshift()   adds an item to the beginning of an array
    array_pop()   removes an item from the end of an array
    array_push()   adds an item to the end of an array
  • Other useful array functions:
    max() & min()   Return the largest and smallest numerical values in the array.
    array_sum()   Adds all the numerical values in an array and returns the sum. Non-numerical values are ignored.
    sort()   Reorders the values in an array into alphabetical (actually "ASCIIbetical" order) or numerical order.
    count()   Returns the number or elements in an array.
    key_exists()   Particularly useful with associative arrays, this returns true if the value provided is a key in the array.


    Prev. Page
    Index Page
    Next Page

    Copyright © 2003
    Henry H. Hartley
    All Rights Reserved