<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 > 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 > 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 > 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 > The constants below are always available as part of the PHP core. </P ><P > <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 > <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 > <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 > <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 > <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 > <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 > <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 > <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 > 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 > -- Returns an array with all string keys lowercased or uppercased</DT ><DT ><A HREF="function.array-chunk.html" >array_chunk</A > -- Split an array into chunks</DT ><DT ><A HREF="function.array-count-values.html" >array_count_values</A > -- Counts all the values of an array</DT ><DT ><A HREF="function.array-diff-assoc.html" >array_diff_assoc</A > -- Computes the difference of arrays with additional index check</DT ><DT ><A HREF="function.array-diff.html" >array_diff</A > -- Computes the difference of arrays</DT ><DT ><A HREF="function.array-fill.html" >array_fill</A > -- Fill an array with values</DT ><DT ><A HREF="function.array-filter.html" >array_filter</A > -- Filters elements of an array using a callback function </DT ><DT ><A HREF="function.array-flip.html" >array_flip</A > -- Exchanges all keys with their associated values in an array</DT ><DT ><A HREF="function.array-intersect-assoc.html" >array_intersect_assoc</A > -- Computes the intersection of arrays with additional index check</DT ><DT ><A HREF="function.array-intersect.html" >array_intersect</A > -- Computes the intersection of arrays</DT ><DT ><A HREF="function.array-key-exists.html" >array_key_exists</A > -- Checks if the given key or index exists in the array</DT ><DT ><A HREF="function.array-keys.html" >array_keys</A > -- Return all the keys of an array</DT ><DT ><A HREF="function.array-map.html" >array_map</A > -- Applies the callback to the elements of the given arrays </DT ><DT ><A HREF="function.array-merge-recursive.html" >array_merge_recursive</A > -- Merge two or more arrays recursively</DT ><DT ><A HREF="function.array-merge.html" >array_merge</A > -- Merge two or more arrays</DT ><DT ><A HREF="function.array-multisort.html" >array_multisort</A > -- Sort multiple or multi-dimensional arrays</DT ><DT ><A HREF="function.array-pad.html" >array_pad</A > -- Pad array to the specified length with a value </DT ><DT ><A HREF="function.array-pop.html" >array_pop</A > -- Pop the element off the end of array</DT ><DT ><A HREF="function.array-push.html" >array_push</A > -- Push one or more elements onto the end of array </DT ><DT ><A HREF="function.array-rand.html" >array_rand</A > -- Pick one or more random entries out of an array </DT ><DT ><A HREF="function.array-reduce.html" >array_reduce</A > -- Iteratively reduce the array to a single value using a callback function </DT ><DT ><A HREF="function.array-reverse.html" >array_reverse</A > -- Return an array with elements in reverse order </DT ><DT ><A HREF="function.array-search.html" >array_search</A > -- 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 > -- Shift an element off the beginning of array </DT ><DT ><A HREF="function.array-slice.html" >array_slice</A > -- Extract a slice of the array</DT ><DT ><A HREF="function.array-splice.html" >array_splice</A > -- Remove a portion of the array and replace it with something else </DT ><DT ><A HREF="function.array-sum.html" >array_sum</A > -- Calculate the sum of values in an array. </DT ><DT ><A HREF="function.array-unique.html" >array_unique</A > -- Removes duplicate values from an array</DT ><DT ><A HREF="function.array-unshift.html" >array_unshift</A > -- Prepend one or more elements to the beginning of array </DT ><DT ><A HREF="function.array-values.html" >array_values</A > -- Return all the values of an array</DT ><DT ><A HREF="function.array-walk.html" >array_walk</A > -- Apply a user function to every member of an array </DT ><DT ><A HREF="function.array.html" >array</A > -- Create an array </DT ><DT ><A HREF="function.arsort.html" >arsort</A > -- Sort an array in reverse order and maintain index association </DT ><DT ><A HREF="function.asort.html" >asort</A > -- Sort an array and maintain index association</DT ><DT ><A HREF="function.compact.html" >compact</A > -- Create array containing variables and their values </DT ><DT ><A HREF="function.count.html" >count</A > -- Count elements in a variable</DT ><DT ><A HREF="function.current.html" >current</A > -- Return the current element in an array</DT ><DT ><A HREF="function.each.html" >each</A > -- Return the current key and value pair from an array and advance the array cursor </DT ><DT ><A HREF="function.end.html" >end</A > -- Set the internal pointer of an array to its last element </DT ><DT ><A HREF="function.extract.html" >extract</A > -- Import variables into the current symbol table from an array </DT ><DT ><A HREF="function.in-array.html" >in_array</A > -- Return <TT CLASS="constant" ><B >TRUE</B ></TT > if a value exists in an array</DT ><DT ><A HREF="function.key.html" >key</A > -- Fetch a key from an associative array</DT ><DT ><A HREF="function.krsort.html" >krsort</A > -- Sort an array by key in reverse order</DT ><DT ><A HREF="function.ksort.html" >ksort</A > -- Sort an array by key</DT ><DT ><A HREF="function.list.html" >list</A > -- Assign variables as if they were an array </DT ><DT ><A HREF="function.natcasesort.html" >natcasesort</A > -- Sort an array using a case insensitive "natural order" algorithm </DT ><DT ><A HREF="function.natsort.html" >natsort</A > -- Sort an array using a "natural order" algorithm </DT ><DT ><A HREF="function.next.html" >next</A > -- Advance the internal array pointer of an array </DT ><DT ><A HREF="function.pos.html" >pos</A > -- Get the current element from an array</DT ><DT ><A HREF="function.prev.html" >prev</A > -- Rewind the internal array pointer</DT ><DT ><A HREF="function.range.html" >range</A > -- Create an array containing a range of elements </DT ><DT ><A HREF="function.reset.html" >reset</A > -- Set the internal pointer of an array to its first element </DT ><DT ><A HREF="function.rsort.html" >rsort</A > -- Sort an array in reverse order</DT ><DT ><A HREF="function.shuffle.html" >shuffle</A > -- Shuffle an array</DT ><DT ><A HREF="function.sizeof.html" >sizeof</A > -- Get the number of elements in variable</DT ><DT ><A HREF="function.sort.html" >sort</A > -- Sort an array</DT ><DT ><A HREF="function.uasort.html" >uasort</A > -- Sort an array with a user-defined comparison function and maintain index association </DT ><DT ><A HREF="function.uksort.html" >uksort</A > -- Sort an array by keys using a user-defined comparison function </DT ><DT ><A HREF="function.usort.html" >usort</A > -- 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 >