Sophie

Sophie

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

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

<HTML
><HEAD
><TITLE
>explode</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="String functions"
HREF="ref.strings.html"><LINK
REL="PREVIOUS"
TITLE="echo"
HREF="function.echo.html"><LINK
REL="NEXT"
TITLE="fprintf"
HREF="function.fprintf.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></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"
>PHP Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.echo.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.fprintf.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.explode"
></A
>explode</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN89317"
></A
><P
>    (PHP 3, PHP 4 )</P
>explode&nbsp;--&nbsp;Split a string by string</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN89320"
></A
><H2
>Description</H2
>array <B
CLASS="methodname"
>explode</B
> ( string separator, string string [, int limit])<BR
></BR
><P
>&#13;     Returns an array of strings, each of which is a substring of
     <TT
CLASS="parameter"
><I
>string</I
></TT
> formed by splitting it on
     boundaries formed by the string <TT
CLASS="parameter"
><I
>separator</I
></TT
>.
     If <TT
CLASS="parameter"
><I
>limit</I
></TT
> is set, the returned array will
     contain a maximum of <TT
CLASS="parameter"
><I
>limit</I
></TT
> elements with
     the last element containing the rest of
     <TT
CLASS="parameter"
><I
>string</I
></TT
>.
    </P
><P
>&#13;     If <TT
CLASS="parameter"
><I
>separator</I
></TT
> is an empty string (""),
     <B
CLASS="function"
>explode()</B
> will return <TT
CLASS="constant"
><B
>FALSE</B
></TT
>.  If
     <TT
CLASS="parameter"
><I
>separator</I
></TT
> contains a value that is not contained
     in <TT
CLASS="parameter"
><I
>string</I
></TT
>, then <B
CLASS="function"
>explode()</B
> will
     return an array containing <TT
CLASS="parameter"
><I
>string</I
></TT
>.
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
      The <TT
CLASS="parameter"
><I
>limit</I
></TT
> parameter was added in PHP
      4.0.1 
     </P
></BLOCKQUOTE
></DIV
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN89352"
></A
><P
><B
>Example 1. <B
CLASS="function"
>explode()</B
> examples</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>$pizza = "piece1 piece2 piece3 piece4 piece5 piece6";
$pieces = explode(" ", $pizza);

$data = "foo:*:1023:1000::/home/foo:/bin/sh";
list($user,$pass,$uid,$gid,$gecos,$home,$shell) = explode(":",$data);</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
      Although <A
HREF="function.implode.html"
><B
CLASS="function"
>implode()</B
></A
> can for historical reasons
      accept its parameters in either order,
      <B
CLASS="function"
>explode()</B
> cannot. You must ensure that the
      <TT
CLASS="parameter"
><I
>separator</I
></TT
> argument comes before the
      <TT
CLASS="parameter"
><I
>string</I
></TT
> argument.
     </P
></BLOCKQUOTE
></DIV
><P
>&#13;     See also 
     <A
HREF="function.preg-split.html"
><B
CLASS="function"
>preg_split()</B
></A
>,
     <A
HREF="function.spliti.html"
><B
CLASS="function"
>spliti()</B
></A
>,
     <A
HREF="function.split.html"
><B
CLASS="function"
>split()</B
></A
>, and
     <A
HREF="function.implode.html"
><B
CLASS="function"
>implode()</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.echo.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.fprintf.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>echo</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.strings.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>fprintf</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>