<?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.5 $ --> <!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 --> <refentry id="function.explode"> <refnamediv> <refname>explode</refname> <refpurpose>Split a string by string</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>array</type><methodname>explode</methodname> <methodparam><type>string</type><parameter>separator</parameter></methodparam> <methodparam><type>string</type><parameter>string</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>limit</parameter></methodparam> </methodsynopsis> <para> Returns an array of strings, each of which is a substring of <parameter>string</parameter> formed by splitting it on boundaries formed by the string <parameter>separator</parameter>. If <parameter>limit</parameter> is set, the returned array will contain a maximum of <parameter>limit</parameter> elements with the last element containing the rest of <parameter>string</parameter>. </para> <para> If <parameter>separator</parameter> is an empty string (""), <function>explode</function> will return &false;. If <parameter>separator</parameter> contains a value that is not contained in <parameter>string</parameter>, then <function>explode</function> will return an array containing <parameter>string</parameter>. </para> <para> Although <function>implode</function> can, for historical reasons, accept its parameters in either order, <function>explode</function> cannot. You must ensure that the <parameter>separator</parameter> argument comes before the <parameter>string</parameter> argument. </para> <note> <para> The <parameter>limit</parameter> parameter was added in PHP 4.0.1 </para> </note> <para> <example> <title><function>explode</function> examples</title> <programlisting role="php"> <![CDATA[ <?php // Example 1 $pizza = "piece1 piece2 piece3 piece4 piece5 piece6"; $pieces = explode(" ", $pizza); print $pieces[0]; // piece1 print $pieces[1]; // piece2 // Example 2 $data = "foo:*:1023:1000::/home/foo:/bin/sh"; list($user,$pass,$uid,$gid,$gecos,$home,$shell) = explode(":",$data); print $user; // foo print $pass; // * ?> ]]> </programlisting> </example> </para> <para> See also <function>preg_split</function>, <function>spliti</function>, <function>split</function>, and <function>implode</function>. </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->