Sophie

Sophie

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

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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML
><HEAD
><TITLE
>array_splice</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_slice"
HREF="function.array-slice.html"><LINK
REL="NEXT"
TITLE="array_sum"
HREF="function.array-sum.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-slice.html"
ACCESSKEY="P"
>Înapoi</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.array-sum.html"
ACCESSKEY="N"
>Înainte</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.array-splice"
></A
>array_splice</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN6621"
></A
><P
>    (PHP 4 , PHP 5)</P
>array_splice&nbsp;--&nbsp;
     Remove a portion of the array and replace it with something
     else
    </DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN6624"
></A
><H2
>Description</H2
>array <B
CLASS="methodname"
>array_splice</B
> ( array input, int offset [, int length [, array replacement]])<BR
></BR
><P
>&#13;     <B
CLASS="function"
>array_splice()</B
> removes the elements designated
     by <VAR
CLASS="parameter"
>offset</VAR
> and
     <VAR
CLASS="parameter"
>length</VAR
> from the
     <VAR
CLASS="parameter"
>input</VAR
> array, and replaces them with the
     elements of the <VAR
CLASS="parameter"
>replacement</VAR
> array, if
     supplied. It returns an array containing the extracted elements.
    </P
><P
>&#13;     If <VAR
CLASS="parameter"
>offset</VAR
> is positive then the start of
     removed portion is at that offset from the beginning of the
     <VAR
CLASS="parameter"
>input</VAR
> array.  If
     <VAR
CLASS="parameter"
>offset</VAR
> is negative then it starts that far
     from the end of the <VAR
CLASS="parameter"
>input</VAR
> array.
    </P
><P
>&#13;     If <VAR
CLASS="parameter"
>length</VAR
> is omitted, removes everything
     from <VAR
CLASS="parameter"
>offset</VAR
> to the end of the array.  If
     <VAR
CLASS="parameter"
>length</VAR
> is specified and is positive, then
     that many elements will be removed. If
     <VAR
CLASS="parameter"
>length</VAR
> is specified and is negative then
     the end of the removed portion will be that many elements from
     the end of the array.  Tip: to remove everything from
     <VAR
CLASS="parameter"
>offset</VAR
> to the end of the array when
     <VAR
CLASS="parameter"
>replacement</VAR
> is also specified, use
     <VAR
CLASS="literal"
>count($input)</VAR
> for
     <VAR
CLASS="parameter"
>length</VAR
>.
    </P
><P
>&#13;     If <VAR
CLASS="parameter"
>replacement</VAR
> array is specified, then
     the removed elements are replaced with elements from this array.
     If <VAR
CLASS="parameter"
>offset</VAR
> and
     <VAR
CLASS="parameter"
>length</VAR
> are such that nothing is removed,
     then the elements from the <VAR
CLASS="parameter"
>replacement</VAR
>
     array are inserted in the place specified by the
     <VAR
CLASS="parameter"
>offset</VAR
>. Tip: if the replacement is just
     one element it is not necessary to put <VAR
CLASS="literal"
>array()</VAR
>
     around it, unless the element is an array itself.
    </P
><P
>&#13;     The following equivalences hold:
     <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
array_push ($input, $x, $y)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array_splice ($input, count ($input), 0,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array ($x, $y))<br />array_pop ($input)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array_splice ($input, -1)<br />array_shift ($input)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array_splice ($input, 0, 1)<br />array_unshift ($input, $x, $y)&nbsp;&nbsp;array_splice ($input, 0, 0, array ($x, $y))<br />$a[$x] = $y&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array_splice ($input, $x, 1, $y)</font>
</code></TD
></TR
></TABLE
>
    </P
><P
>&#13;     Returns the array consisting of removed elements.
    </P
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN6672"
></A
><P
><B
>Exemplu 1. <B
CLASS="function"
>array_splice()</B
> examples</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
$input = array ("red", "green", "blue", "yellow");<br />array_splice ($input, 2);<br />// $input is now array ("red", "green")<br /><br />$input = array ("red", "green", "blue", "yellow");<br />array_splice ($input, 1, -1);<br />// $input is now array ("red", "yellow")<br /><br />$input = array ("red", "green", "blue", "yellow");<br />array_splice ($input, 1, count($input), "orange");<br />// $input is now array ("red", "orange")<br /><br />$input = array ("red", "green", "blue", "yellow");<br />array_splice ($input, -1, 1, array("black", "maroon"));<br />// $input is now array ("red", "green",<br />//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"blue", "black", "maroon")</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     See also <A
HREF="function.array-slice.html"
><B
CLASS="function"
>array_slice()</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-slice.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.array-sum.html"
ACCESSKEY="N"
>Înainte</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>array_slice</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"
>array_sum</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>