Sophie

Sophie

distrib > PLD > ac > amd64 > media > dist > by-pkgid > dd8ef74e7a184506d40e4328053fb785 > files > 145

php-manual-ro-20051028-1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML
><HEAD
><TITLE
>array</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Manual PHP"
HREF="index.html"><LINK
REL="UP"
TITLE="Array - funcþii"
HREF="ref.array.html"><LINK
REL="PREVIOUS"
TITLE="array_walk"
HREF="function.array-walk.html"><LINK
REL="NEXT"
TITLE="arsort"
HREF="function.arsort.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-2"></HEAD
><BODY
CLASS="refentry"
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 PHP</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.array-walk.html"
ACCESSKEY="P"
>Înapoi</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.arsort.html"
ACCESSKEY="N"
>Înainte</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.array"
></A
>array</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN7044"
></A
><P
>    (PHP 3, PHP 4, PHP 5 )</P
>array&nbsp;--&nbsp;
     Creeazã un tablou.
    </DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN7047"
></A
><H2
>Descriere</H2
>array <B
CLASS="methodname"
>array</B
> ( [mixed ...])<BR
></BR
><P
>&#13;    Returneazã un tablou format din parametri. Parametrii pot deveni indecºi 
	utilizând operatorul  <VAR
CLASS="literal"
>=&#62;</VAR
>.
    </P
><P
>&#13;     <DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Not&#227;: </B
>
       <B
CLASS="function"
>array()</B
> este un constructor al limbajului PHP
	   utilizat pentru a reprezenta tablourile, ºi nu o funcþie propriu-zisã.
      </P
></BLOCKQUOTE
></DIV
>
    </P
><P
>&#13;     Sintaxa "index =&#62; values", separatã de virgule, defineºte indecºi
	 ºi valori. Indecºii pot fi de tipul ºir de caractere sau numerici. Când sunt omiºi,
	 indecºii sunt generaþi automat sub forma unor numere întregi, începând
	 cu 0. Atunci când un index este un numãr întreg, urmãtorul index generat va fi
	 cel mai mare index din tablou, incrementat cu 1. Dacã sunt definiþi doi indecºi identici,
	 ultimul îl va suprascrie pe primul.
    </P
><P
>&#13;     Urmãtorul exemplu demonstreazã cum se creeazã un
	 tablou bidimensional, cum se specificã cheile
	 pentru tablouri asociative ºi cum sã sãriþi peste indicii numerici
	 în tablouri normale.
     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN7063"
></A
><P
><B
>Exemplu 1. Exempul de utilizare al funcþiei <B
CLASS="function"
>array()</B
></B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
$fruits = array (<br />&nbsp;&nbsp;&nbsp;&nbsp;"fruits"&nbsp;&nbsp;=&gt; array ("a"=&gt;"orange", "b"=&gt;"banana", "c"=&gt;"apple"),<br />&nbsp;&nbsp;&nbsp;&nbsp;"numbers" =&gt; array (1, 2, 3, 4, 5, 6),<br />&nbsp;&nbsp;&nbsp;&nbsp;"holes"&nbsp;&nbsp;&nbsp;=&gt; array ("first", 5 =&gt; "second", "third")<br />);</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN7068"
></A
><P
><B
>Exemplu 2. Indecºi automaþi cu <B
CLASS="function"
>array()</B
></B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
$array = array( 1, 1, 1, 1,&nbsp;&nbsp;1, 8=&gt;1,&nbsp;&nbsp;4=&gt;1, 19, 3=&gt;13);<br />print_r($array);</font>
</code></TD
></TR
></TABLE
><P
>&#13;       va afiºa :
       <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
Array<br />(<br />&nbsp;&nbsp;&nbsp;&nbsp;[0] =&gt; 1<br />&nbsp;&nbsp;&nbsp;&nbsp;[1] =&gt; 1<br />&nbsp;&nbsp;&nbsp;&nbsp;[2] =&gt; 1<br />&nbsp;&nbsp;&nbsp;&nbsp;[3] =&gt; 13<br />&nbsp;&nbsp;&nbsp;&nbsp;[4] =&gt; 1<br />&nbsp;&nbsp;&nbsp;&nbsp;[8] =&gt; 1<br />&nbsp;&nbsp;&nbsp;&nbsp;[9] =&gt; 19<br />)</font>
</code></TD
></TR
></TABLE
>
      </P
></DIV
></TD
></TR
></TABLE
>
     Observaþi cã indexul '3' este definit de douã ori ºi cã pãstreazã valoarea finalã 13.
     Indexul 4 este definit dupã indexul 8, iar urmãtorul index generat (valoarea 19)
     este 9, întrucât cel mai mare index era 8.
    </P
><P
>&#13;     În exemplul urmãtor vom crea un tablou cu baza 1.
     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN7075"
></A
><P
><B
>Exemplu 3. index bazat pe 1 cu <B
CLASS="function"
>array()</B
></B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
$firstquarter&nbsp;&nbsp;= array(1 =&gt; 'January', 'February', 'March');<br />print_r($firstquarter);</font>
</code></TD
></TR
></TABLE
><P
>&#13;       will display :
       <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>Array
(
    [1] =&#62; 'January'
    [2] =&#62; 'February'
    [3] =&#62; 'March'
)</PRE
></TD
></TR
></TABLE
>
      </P
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     Vezi, de asemenea, ºi <A
HREF="function.array-pad.html"
><B
CLASS="function"
>array_pad()</B
></A
>,
     <A
HREF="function.list.html"
><B
CLASS="function"
>list()</B
></A
>, precum ºi <A
HREF="function.range.html"
><B
CLASS="function"
>range()</B
></A
>.
    </P
></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.array-walk.html"
ACCESSKEY="P"
>Înapoi</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Acas&#227;</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.arsort.html"
ACCESSKEY="N"
>Înainte</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>array_walk</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.array.html"
ACCESSKEY="U"
>Sus</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>arsort</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>