Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > media > main > by-pkgid > 0afeee9cca140e167a996902b9a677c5 > files > 3046

php-manual-en-4.3.0-2mdk.noarch.rpm

<HTML
><HEAD
><TITLE
>Array Functions</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="PHP Manual"
HREF="index.html"><LINK
REL="UP"
TITLE="Function Reference"
HREF="funcref.html"><LINK
REL="PREVIOUS"
TITLE="virtual"
HREF="function.virtual.html"><LINK
REL="NEXT"
TITLE="array_change_key_case"
HREF="function.array-change-key-case.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="reference"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.virtual.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.array-change-key-case.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="reference"
><A
NAME="ref.array"
></A
><DIV
CLASS="TITLEPAGE"
><H1
CLASS="title"
>II. Array Functions</H1
><DIV
CLASS="PARTINTRO"
><A
NAME="AEN7121"
></A
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="array.intro"
></A
>Introduction</H1
><P
>&#13;     These functions allow you to interact with and manipulate
     arrays in various ways. Arrays are essential for storing,
     managing, and operating on sets of variables.
    </P
><P
>&#13;     Simple and multi-dimensional arrays are supported, and may be
     either user created or created by another function.
     There are specific database handling functions for populating
     arrays from database queries, and several functions return arrays.
    </P
><P
>&#13;     Please see the <A
HREF="language.types.array.html"
>Arrays</A
>
     section of the manual for a detailed explanation of how arrays are
     implemented and used in PHP.
    </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="array.requirements"
></A
>Requirements</H1
><P
>No external libraries are needed to build this extension.</P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="array.installation"
></A
>Installation</H1
><P
>There is no installation needed to use these
functions; they are part of the PHP core.</P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="array.configuration"
></A
>Runtime Configuration</H1
><P
>This extension has no configuration directives defined in <TT
CLASS="filename"
>php.ini</TT
>.</P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="array.resources"
></A
>Resource Types</H1
><P
>This extension has no resource types defined.</P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="array.constants"
></A
>Predefined Constants</H1
><P
>&#13;The constants below are always available as part of the PHP core.
</P
><P
>&#13; <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><TT
CLASS="constant"
><B
>CASE_LOWER</B
></TT
>
    (<A
HREF="language.types.integer.html"
>integer</A
>)</DT
><DD
><P
>&#13;     <TT
CLASS="constant"
><B
>CASE_LOWER</B
></TT
> is used with
     <A
HREF="function.array-change-key-case.html"
><B
CLASS="function"
>array_change_key_case()</B
></A
> and is used to convert array
     keys to lower case. This is also the default case for
     <A
HREF="function.array-change-key-case.html"
><B
CLASS="function"
>array_change_key_case()</B
></A
>.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>CASE_UPPER</B
></TT
>
    (<A
HREF="language.types.integer.html"
>integer</A
>)</DT
><DD
><P
>&#13;     <TT
CLASS="constant"
><B
>CASE_UPPER</B
></TT
> is used with
     <A
HREF="function.array-change-key-case.html"
><B
CLASS="function"
>array_change_key_case()</B
></A
> and is used to convert array
     keys to upper case.
    </P
></DD
></DL
></DIV
>
 </P
><P
> Sorting order flags:
 <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><TT
CLASS="constant"
><B
>SORT_ASC</B
></TT
> 
    (<A
HREF="language.types.integer.html"
>integer</A
>)</DT
><DD
><P
>&#13;     <TT
CLASS="constant"
><B
>SORT_ASC</B
></TT
> is used with
     <A
HREF="function.array-multisort.html"
><B
CLASS="function"
>array_multisort()</B
></A
> to sort in ascending order.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SORT_DESC</B
></TT
> 
    (<A
HREF="language.types.integer.html"
>integer</A
>)</DT
><DD
><P
>&#13;     <TT
CLASS="constant"
><B
>SORT_DESC</B
></TT
> is used with
     <A
HREF="function.array-multisort.html"
><B
CLASS="function"
>array_multisort()</B
></A
> to sort in descending order.
    </P
></DD
></DL
></DIV
>
 </P
><P
> Sorting type flags: used by various sort functions
 <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><TT
CLASS="constant"
><B
>SORT_REGULAR</B
></TT
> 
    (<A
HREF="language.types.integer.html"
>integer</A
>)</DT
><DD
><P
>&#13;     <TT
CLASS="constant"
><B
>SORT_REGULAR</B
></TT
> is used to compare items normally.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SORT_NUMERIC</B
></TT
> 
    (<A
HREF="language.types.integer.html"
>integer</A
>)</DT
><DD
><P
>&#13;     <TT
CLASS="constant"
><B
>SORT_NUMERIC</B
></TT
> is used to compare items numerically.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SORT_STRING</B
></TT
> 
    (<A
HREF="language.types.integer.html"
>integer</A
>)</DT
><DD
><P
>&#13;    <TT
CLASS="constant"
><B
>SORT_STRING</B
></TT
> is used to compare items as strings.
    </P
></DD
></DL
></DIV
>
 </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="array.seealso"
></A
>See Also</H1
><P
>&#13;     See also <A
HREF="function.is-array.html"
><B
CLASS="function"
>is_array()</B
></A
>, <A
HREF="function.explode.html"
><B
CLASS="function"
>explode()</B
></A
>,
     <A
HREF="function.implode.html"
><B
CLASS="function"
>implode()</B
></A
>, <A
HREF="function.split.html"
><B
CLASS="function"
>split()</B
></A
>,
     <A
HREF="function.preg-split.html"
><B
CLASS="function"
>preg_split()</B
></A
>, and <A
HREF="function.join.html"
><B
CLASS="function"
>join()</B
></A
>.
    </P
></DIV
></DIV
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
><A
HREF="function.array-change-key-case.html"
>array_change_key_case</A
>&nbsp;--&nbsp;Returns an array with all string keys lowercased or uppercased</DT
><DT
><A
HREF="function.array-chunk.html"
>array_chunk</A
>&nbsp;--&nbsp;Split an array into chunks</DT
><DT
><A
HREF="function.array-count-values.html"
>array_count_values</A
>&nbsp;--&nbsp;Counts all the values of an array</DT
><DT
><A
HREF="function.array-diff-assoc.html"
>array_diff_assoc</A
>&nbsp;--&nbsp;Computes the difference of arrays with additional index check</DT
><DT
><A
HREF="function.array-diff.html"
>array_diff</A
>&nbsp;--&nbsp;Computes the difference of arrays</DT
><DT
><A
HREF="function.array-fill.html"
>array_fill</A
>&nbsp;--&nbsp;Fill an array with values</DT
><DT
><A
HREF="function.array-filter.html"
>array_filter</A
>&nbsp;--&nbsp;
     Filters elements of an array using a callback function
    </DT
><DT
><A
HREF="function.array-flip.html"
>array_flip</A
>&nbsp;--&nbsp;Exchanges all keys with their associated values in an array</DT
><DT
><A
HREF="function.array-intersect-assoc.html"
>array_intersect_assoc</A
>&nbsp;--&nbsp;Computes the intersection of arrays with additional index check</DT
><DT
><A
HREF="function.array-intersect.html"
>array_intersect</A
>&nbsp;--&nbsp;Computes the intersection of arrays</DT
><DT
><A
HREF="function.array-key-exists.html"
>array_key_exists</A
>&nbsp;--&nbsp;Checks if the given key or index exists in the array</DT
><DT
><A
HREF="function.array-keys.html"
>array_keys</A
>&nbsp;--&nbsp;Return all the keys of an array</DT
><DT
><A
HREF="function.array-map.html"
>array_map</A
>&nbsp;--&nbsp;
     Applies the callback to the elements of the given arrays
    </DT
><DT
><A
HREF="function.array-merge-recursive.html"
>array_merge_recursive</A
>&nbsp;--&nbsp;Merge two or more arrays recursively</DT
><DT
><A
HREF="function.array-merge.html"
>array_merge</A
>&nbsp;--&nbsp;Merge two or more arrays</DT
><DT
><A
HREF="function.array-multisort.html"
>array_multisort</A
>&nbsp;--&nbsp;Sort multiple or multi-dimensional arrays</DT
><DT
><A
HREF="function.array-pad.html"
>array_pad</A
>&nbsp;--&nbsp;
     Pad array to the specified length with a value
    </DT
><DT
><A
HREF="function.array-pop.html"
>array_pop</A
>&nbsp;--&nbsp;Pop the element off the end of array</DT
><DT
><A
HREF="function.array-push.html"
>array_push</A
>&nbsp;--&nbsp;
     Push one or more elements onto the end of array
    </DT
><DT
><A
HREF="function.array-rand.html"
>array_rand</A
>&nbsp;--&nbsp;
     Pick one or more random entries out of an array
    </DT
><DT
><A
HREF="function.array-reduce.html"
>array_reduce</A
>&nbsp;--&nbsp;
     Iteratively reduce the array to a single value using a callback
     function
    </DT
><DT
><A
HREF="function.array-reverse.html"
>array_reverse</A
>&nbsp;--&nbsp;
     Return an array with elements in reverse order
    </DT
><DT
><A
HREF="function.array-search.html"
>array_search</A
>&nbsp;--&nbsp;
     Searches the array for a given value and returns the
     corresponding key if successful
    </DT
><DT
><A
HREF="function.array-shift.html"
>array_shift</A
>&nbsp;--&nbsp;
     Shift an element off the beginning of array
    </DT
><DT
><A
HREF="function.array-slice.html"
>array_slice</A
>&nbsp;--&nbsp;Extract a slice of the array</DT
><DT
><A
HREF="function.array-splice.html"
>array_splice</A
>&nbsp;--&nbsp;
     Remove a portion of the array and replace it with something
     else
    </DT
><DT
><A
HREF="function.array-sum.html"
>array_sum</A
>&nbsp;--&nbsp;
     Calculate the sum of values in an array.
    </DT
><DT
><A
HREF="function.array-unique.html"
>array_unique</A
>&nbsp;--&nbsp;Removes duplicate values from an array</DT
><DT
><A
HREF="function.array-unshift.html"
>array_unshift</A
>&nbsp;--&nbsp;
     Prepend one or more elements to the beginning of array
    </DT
><DT
><A
HREF="function.array-values.html"
>array_values</A
>&nbsp;--&nbsp;Return all the values of an array</DT
><DT
><A
HREF="function.array-walk.html"
>array_walk</A
>&nbsp;--&nbsp;
     Apply a user function to every member of an array
    </DT
><DT
><A
HREF="function.array.html"
>array</A
>&nbsp;--&nbsp;
     Create an array
    </DT
><DT
><A
HREF="function.arsort.html"
>arsort</A
>&nbsp;--&nbsp;
     Sort an array in reverse order and maintain index association
    </DT
><DT
><A
HREF="function.asort.html"
>asort</A
>&nbsp;--&nbsp;Sort an array and maintain index association</DT
><DT
><A
HREF="function.compact.html"
>compact</A
>&nbsp;--&nbsp;
     Create array containing variables and their values
    </DT
><DT
><A
HREF="function.count.html"
>count</A
>&nbsp;--&nbsp;Count elements in a variable</DT
><DT
><A
HREF="function.current.html"
>current</A
>&nbsp;--&nbsp;Return the current element in an array</DT
><DT
><A
HREF="function.each.html"
>each</A
>&nbsp;--&nbsp;
     Return the current key and value pair from an array and advance
     the array cursor
    </DT
><DT
><A
HREF="function.end.html"
>end</A
>&nbsp;--&nbsp;
     Set the internal pointer of an array to its last element
    </DT
><DT
><A
HREF="function.extract.html"
>extract</A
>&nbsp;--&nbsp;
     Import variables into the current symbol table from an array
    </DT
><DT
><A
HREF="function.in-array.html"
>in_array</A
>&nbsp;--&nbsp;Return <TT
CLASS="constant"
><B
>TRUE</B
></TT
> if a value exists in an array</DT
><DT
><A
HREF="function.key.html"
>key</A
>&nbsp;--&nbsp;Fetch a key from an associative array</DT
><DT
><A
HREF="function.krsort.html"
>krsort</A
>&nbsp;--&nbsp;Sort an array by key in reverse order</DT
><DT
><A
HREF="function.ksort.html"
>ksort</A
>&nbsp;--&nbsp;Sort an array by key</DT
><DT
><A
HREF="function.list.html"
>list</A
>&nbsp;--&nbsp;
     Assign variables as if they were an array
    </DT
><DT
><A
HREF="function.natcasesort.html"
>natcasesort</A
>&nbsp;--&nbsp;
     Sort an array using a case insensitive "natural order" algorithm
    </DT
><DT
><A
HREF="function.natsort.html"
>natsort</A
>&nbsp;--&nbsp;
     Sort an array using a "natural order" algorithm
    </DT
><DT
><A
HREF="function.next.html"
>next</A
>&nbsp;--&nbsp;
     Advance the internal array pointer of an array
    </DT
><DT
><A
HREF="function.pos.html"
>pos</A
>&nbsp;--&nbsp;Get the current element from an array</DT
><DT
><A
HREF="function.prev.html"
>prev</A
>&nbsp;--&nbsp;Rewind the internal array pointer</DT
><DT
><A
HREF="function.range.html"
>range</A
>&nbsp;--&nbsp;
     Create an array containing a range of elements
    </DT
><DT
><A
HREF="function.reset.html"
>reset</A
>&nbsp;--&nbsp;
     Set the internal pointer of an array to its first element
    </DT
><DT
><A
HREF="function.rsort.html"
>rsort</A
>&nbsp;--&nbsp;Sort an array in reverse order</DT
><DT
><A
HREF="function.shuffle.html"
>shuffle</A
>&nbsp;--&nbsp;Shuffle an array</DT
><DT
><A
HREF="function.sizeof.html"
>sizeof</A
>&nbsp;--&nbsp;Get the number of elements in variable</DT
><DT
><A
HREF="function.sort.html"
>sort</A
>&nbsp;--&nbsp;Sort an array</DT
><DT
><A
HREF="function.uasort.html"
>uasort</A
>&nbsp;--&nbsp;
     Sort an array with a user-defined comparison function and
     maintain index association
    </DT
><DT
><A
HREF="function.uksort.html"
>uksort</A
>&nbsp;--&nbsp;
     Sort an array by keys using a user-defined comparison function
    </DT
><DT
><A
HREF="function.usort.html"
>usort</A
>&nbsp;--&nbsp;
     Sort an array by values using a user-defined comparison function
    </DT
></DL
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.virtual.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.array-change-key-case.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>virtual</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="funcref.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>array_change_key_case</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>