<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >Arrays</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="Manual do PHP" HREF="index.html"><LINK REL="UP" TITLE="Referência das Funções" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="rename_function" HREF="function.rename-function.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=UTF-8"></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" >Manual do PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.rename-function.html" ACCESSKEY="P" >Anterior</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" >Próxima</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.array" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >V. Arrays</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN10011" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="array.intro" >Introdução</A ></H1 ><P > Essas funções permitem a interação e manipulação de arrays de várias formas. Arrays são essenciais para armazenar, gerenciar, operar sobre um conjunto de variáveis. </P ><P > Arrays simples e multidimensionais (matrizes) são suportados, e podem ser criados pelo usuário ou por outras funções. Existem diversas funções específicas para bancos de dados para preencher arrays com os dados retornados em consultas, e vários outros tipos de funções também retornam arrays. </P ><P > Por favor, veja a seção <A HREF="language.types.array.html" >Arrays</A > do manual para uma explicação mais detalhada sobre como arrays são implementados e utilizados no PHP. Veja também <A HREF="language.operators.array.html" >Operadores de Array</A > para outras maneiras de manipular matrizes. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="array.requirements" >Dependências</A ></H1 ><P >Nenhuma biblioteca externa é necessária para compilar esta extensão.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="array.installation" >Instalação</A ></H1 ><P >Não há nenhuma instalação necessária para utilizar estas funções, elas fazem parte do núcleo do PHP.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="array.configuration" >Configurações em execução</A ></H1 ><P >Esta extensão não define nenhum parâmetro de configuração no <TT CLASS="filename" >php.ini</TT >.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="array.resources" >Tipos Resource</A ></H1 ><P >Esta extensão não possui nenhum tipo resource.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="array.constants" >Constantes pré-definidas</A ></H1 ><P > As constantes listadas abaixo estão sempre disponíveis como parte do núcleo do PHP. </P ><P > <P ></P ><DIV CLASS="variablelist" ><DL ><DT ><TT CLASS="constant" ><B >CASE_LOWER</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > <TT CLASS="constant" ><B >CASE_LOWER</B ></TT > é usada com a função <A HREF="function.array-change-key-case.html" ><B CLASS="function" >array_change_key_case()</B ></A > e é usada em chaves de arrays para torná-las minúsculas. É o valor padrão utilizado em <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" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > <TT CLASS="constant" ><B >CASE_UPPER</B ></TT > é usada com a função <A HREF="function.array-change-key-case.html" ><B CLASS="function" >array_change_key_case()</B ></A > e é usada em chaves de arrays para torná-las maiúsculas. </P ></DD ></DL ></DIV > </P ><P > Sinais de ordenação: <P ></P ><DIV CLASS="variablelist" ><DL ><DT ><TT CLASS="constant" ><B >SORT_ASC</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > <TT CLASS="constant" ><B >SORT_ASC</B ></TT > é usada com <A HREF="function.array-multisort.html" ><B CLASS="function" >array_multisort()</B ></A > para ordenar em ordem crescente. </P ></DD ><DT ><TT CLASS="constant" ><B >SORT_DESC</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > <TT CLASS="constant" ><B >SORT_DESC</B ></TT > é usada com <A HREF="function.array-multisort.html" ><B CLASS="function" >array_multisort()</B ></A > para ordenar em ordem descrescente </P ></DD ></DL ></DIV > </P ><P > Sinais de tipos de ordenação: usadas por várias funções de ordenação <P ></P ><DIV CLASS="variablelist" ><DL ><DT ><TT CLASS="constant" ><B >SORT_REGULAR</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > <TT CLASS="constant" ><B >SORT_REGULAR</B ></TT > é usada para comparar itens normalmente. </P ></DD ><DT ><TT CLASS="constant" ><B >SORT_NUMERIC</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > <TT CLASS="constant" ><B >SORT_NUMERIC</B ></TT > é usada para comparar itens numericamente. </P ></DD ><DT ><TT CLASS="constant" ><B >SORT_STRING</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > <TT CLASS="constant" ><B >SORT_STRING</B ></TT > é usada para comparar itens como se fossem strings. </P ></DD ><DT ><TT CLASS="constant" ><B >SORT_LOCALE_STRING</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > <TT CLASS="constant" ><B >SORT_LOCALE_STRING</B ></TT > é usada para comparar itens como se fossem strings, baseado no local atual. Adicionado no PHP 4.4.0 e 5.0.2. </P ></DD ></DL ></DIV > </P ><P ></P ><DIV CLASS="variablelist" ><DL ><DT ><TT CLASS="constant" ><B >COUNT_NORMAL</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >COUNT_RECURSIVE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >EXTR_OVERWRITE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >EXTR_SKIP</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >EXTR_PREFIX_SAME</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >EXTR_PREFIX_ALL</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >EXTR_PREFIX_INVALID</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >EXTR_PREFIX_IF_EXISTS</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >EXTR_IF_EXISTS</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >EXTR_REFS</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ></DL ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="array.seealso" >Veja também</A ></H1 ><P > Veja também <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 > e <A HREF="function.unset.html" ><B CLASS="function" >unset()</B ></A >. </P ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Índice</B ></DT ><DT ><A HREF="function.array-change-key-case.html" >array_change_key_case</A > -- Retorna um array com todas as chaves string em maiúsculo ou minúsculo</DT ><DT ><A HREF="function.array-chunk.html" >array_chunk</A > -- Divide um array em pedaços</DT ><DT ><A HREF="function.array-combine.html" >array_combine</A > -- Creates an array by using one array for keys and another for its values</DT ><DT ><A HREF="function.array-count-values.html" >array_count_values</A > -- Conta as frequências de cada valor de um 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-key.html" >array_diff_key</A > -- Computes the difference of arrays using keys for comparison</DT ><DT ><A HREF="function.array-diff-uassoc.html" >array_diff_uassoc</A > -- Computes the difference of arrays with additional index check which is performed by a user supplied callback function</DT ><DT ><A HREF="function.array-diff-ukey.html" >array_diff_ukey</A > -- Computes the difference of arrays using a callback function on the keys for comparison</DT ><DT ><A HREF="function.array-diff.html" >array_diff</A > -- Analisa as diferenças entre arrays</DT ><DT ><A HREF="function.array-fill-keys.html" >array_fill_keys</A > -- Fill an array with values, specifying keys</DT ><DT ><A HREF="function.array-fill.html" >array_fill</A > -- Preenche um array com valores</DT ><DT ><A HREF="function.array-filter.html" >array_filter</A > -- Filtra os elementos da array usando uma função de callback</DT ><DT ><A HREF="function.array-flip.html" >array_flip</A > -- Inverte as relações entre chaves e valores</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-key.html" >array_intersect_key</A > -- Computes the intersection of arrays using keys for comparison</DT ><DT ><A HREF="function.array-intersect-uassoc.html" >array_intersect_uassoc</A > -- Computes the intersection of arrays with additional index check, compares indexes by a callback function</DT ><DT ><A HREF="function.array-intersect-ukey.html" >array_intersect_ukey</A > -- Computes the intersection of arrays using a callback function on the keys for comparison</DT ><DT ><A HREF="function.array-intersect.html" >array_intersect</A > -- Calcula a interseção entre arrays</DT ><DT ><A HREF="function.array-key-exists.html" >array_key_exists</A > -- Checa se uma chave ou índice existe em um array</DT ><DT ><A HREF="function.array-keys.html" >array_keys</A > -- Retorna todas as chaves de um array</DT ><DT ><A HREF="function.array-map.html" >array_map</A > -- Aplica uma função em todos os elementos dos arrays dados</DT ><DT ><A HREF="function.array-merge-recursive.html" >array_merge_recursive</A > -- Funde dois ou mais arrays recursivamente</DT ><DT ><A HREF="function.array-merge.html" >array_merge</A > -- Funde um ou mais arrays</DT ><DT ><A HREF="function.array-multisort.html" >array_multisort</A > -- Ordena múltiplos arrays ou arrays multi-dimensionais</DT ><DT ><A HREF="function.array-pad.html" >array_pad</A > -- Expande um array para um certo comprimento utilizando um determinado valor</DT ><DT ><A HREF="function.array-pop.html" >array_pop</A > -- Retira um elemento do final do array</DT ><DT ><A HREF="function.array-product.html" >array_product</A > -- Calculate the product of values in an array</DT ><DT ><A HREF="function.array-push.html" >array_push</A > -- Adiciona um ou mais elementos no final de um array</DT ><DT ><A HREF="function.array-rand.html" >array_rand</A > -- Retorna um ou mais elementos aleatórios de um array</DT ><DT ><A HREF="function.array-reduce.html" >array_reduce</A > -- Reduz um array para um único valor através de um processo iterativo utilizando uma função.</DT ><DT ><A HREF="function.array-reverse.html" >array_reverse</A > -- Retorna um array com os elementos na ordem inversa</DT ><DT ><A HREF="function.array-search.html" >array_search</A > -- Procura por um valor em um array e retorna sua chave correspondente caso seja encontrado</DT ><DT ><A HREF="function.array-shift.html" >array_shift</A > -- Retira o primeiro elemento de um array</DT ><DT ><A HREF="function.array-slice.html" >array_slice</A > -- Extrai uma parcela de um array</DT ><DT ><A HREF="function.array-splice.html" >array_splice</A > -- Remove uma parcela do array e substitui com outros elementos</DT ><DT ><A HREF="function.array-sum.html" >array_sum</A > -- Calcula a soma dos elementos de um array</DT ><DT ><A HREF="function.array-udiff-assoc.html" >array_udiff_assoc</A > -- Computes the difference of arrays with additional index check, compares data by a callback function</DT ><DT ><A HREF="function.array-udiff-uassoc.html" >array_udiff_uassoc</A > -- Computes the difference of arrays with additional index check, compares data and indexes by a callback function</DT ><DT ><A HREF="function.array-udiff.html" >array_udiff</A > -- Computes the difference of arrays by using a callback function for data comparison</DT ><DT ><A HREF="function.array-uintersect-assoc.html" >array_uintersect_assoc</A > -- Computes the intersection of arrays with additional index check, compares data by a callback function</DT ><DT ><A HREF="function.array-uintersect-uassoc.html" >array_uintersect_uassoc</A > -- Computes the intersection of arrays with additional index check, compares data and indexes by a callback functions</DT ><DT ><A HREF="function.array-uintersect.html" >array_uintersect</A > -- Computes the intersection of arrays, compares data by a callback function</DT ><DT ><A HREF="function.array-unique.html" >array_unique</A > -- Remove o valores duplicados de um array</DT ><DT ><A HREF="function.array-unshift.html" >array_unshift</A > -- Adiciona um ou mais elementos no início de um array </DT ><DT ><A HREF="function.array-values.html" >array_values</A > -- Retorna todos os valores de um array</DT ><DT ><A HREF="function.array-walk-recursive.html" >array_walk_recursive</A > -- Apply a user function recursively to every member of an array</DT ><DT ><A HREF="function.array-walk.html" >array_walk</A > -- Aplica uma determinada funcão em cada elemento de um array </DT ><DT ><A HREF="function.array.html" >array</A > -- Cria um array</DT ><DT ><A HREF="function.arsort.html" >arsort</A > -- Ordena um array em ordem descrescente mantendo a associação entre índices e valores</DT ><DT ><A HREF="function.asort.html" >asort</A > -- Ordena um array mantendo a associação entre índices e valores </DT ><DT ><A HREF="function.compact.html" >compact</A > -- Cria um array contendo variáveis e seus valores</DT ><DT ><A HREF="function.count.html" >count</A > -- Conta o número de elementos de uma variável</DT ><DT ><A HREF="function.current.html" >current</A > -- Retorna o elemento corrente em um array</DT ><DT ><A HREF="function.each.html" >each</A > -- Retorna o par chave/valor corrente de um array e avança o seu cursor </DT ><DT ><A HREF="function.end.html" >end</A > -- Faz o ponteiro interno de um array apontar para o seu último elemento </DT ><DT ><A HREF="function.extract.html" >extract</A > -- Importa variáveis para a tabela de símbolos a partir de um array </DT ><DT ><A HREF="function.in-array.html" >in_array</A > -- Checa se um valor existe em um array</DT ><DT ><A HREF="function.key.html" >key</A > -- Retorna uma chave de um array associativo</DT ><DT ><A HREF="function.krsort.html" >krsort</A > -- Ordena um array pelas chaves em ordem descrescente</DT ><DT ><A HREF="function.ksort.html" >ksort</A > -- Ordena um array pelas chaves</DT ><DT ><A HREF="function.list.html" >list</A > -- Cria variáveis como se fossem arrays </DT ><DT ><A HREF="function.natcasesort.html" >natcasesort</A > -- Ordena um array utilizando o algoritmo da "ordem natural" sem diferenciar maiúsculas e minúsculas </DT ><DT ><A HREF="function.natsort.html" >natsort</A > -- Ordena um array utilizando o algoritmo da "ordem natural" </DT ><DT ><A HREF="function.next.html" >next</A > -- Avança o ponteiro interno de um array </DT ><DT ><A HREF="function.pos.html" >pos</A > -- Retorna o elemento atual do array</DT ><DT ><A HREF="function.prev.html" >prev</A > -- Retrocede o ponteiro interno de um array</DT ><DT ><A HREF="function.range.html" >range</A > -- Cria um array contendo uma faixa de elementos </DT ><DT ><A HREF="function.reset.html" >reset</A > -- Faz o ponteiro interno de um array apontar para o seu primeiro elemento </DT ><DT ><A HREF="function.rsort.html" >rsort</A > -- Ordena um array em ordem descrescente</DT ><DT ><A HREF="function.shuffle.html" >shuffle</A > -- Mistura os elementos de um array</DT ><DT ><A HREF="function.sizeof.html" >sizeof</A > -- Apelido de <A HREF="function.count.html" ><B CLASS="function" >count()</B ></A ></DT ><DT ><A HREF="function.sort.html" >sort</A > -- Ordena um array</DT ><DT ><A HREF="function.uasort.html" >uasort</A > -- Ordena um array utilizando uma função de comparação definida pelo usuário e mantendo as associações entre chaves e valores </DT ><DT ><A HREF="function.uksort.html" >uksort</A > -- Ordena um array pelas chaves utilizando uma função de comparação definida pelo usuário. </DT ><DT ><A HREF="function.usort.html" >usort</A > -- Ordena um array pelos valores utilizando uma função de comparação definida pelo usuário </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.rename-function.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Principal</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.array-change-key-case.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >rename_function</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >array_change_key_case</TD ></TR ></TABLE ></DIV ></BODY ></HTML >