php-doc-en/reference/pcre/functions/preg-split.xml
Hartmut Holzgraefe 5b9fc29465 revision tags added
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@78496 c90b9560-bf6c-de11-be94-00142212c4b1
2002-04-17 06:45:35 +00:00

118 lines
3.5 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- splitted from ./en/functions/pcre.xml, last change in rev 1.2 -->
<refentry id="function.preg-split">
<refnamediv>
<refname>preg_split</refname>
<refpurpose>Split string by a regular expression</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>array</type><methodname>preg_split</methodname>
<methodparam><type>string</type><parameter>pattern</parameter></methodparam>
<methodparam><type>string</type><parameter>subject</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>limit</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>flags</parameter></methodparam>
</methodsynopsis>
<note>
<para>
Parameter <parameter>flags</parameter> was added in PHP 4 Beta 3.
</para>
</note>
<para>
Returns an array containing substrings of
<parameter>subject</parameter> split along boundaries matched by
<parameter>pattern</parameter>.
</para>
<para>
If <parameter>limit</parameter> is specified, then only substrings up to
<parameter>limit</parameter> are returned, and if
<parameter>limit</parameter> is -1, it actually means "no limit", which is
useful for specifying the <parameter>flags</parameter>.
</para>
<para>
<parameter>flags</parameter> can be any combination of the following flags
(combined with bitwise | operator):
<variablelist>
<varlistentry>
<term>PREG_SPLIT_NO_EMPTY</term>
<listitem>
<simpara>
If this flag is set, only non-empty pieces will be returned by
<function>preg_split</function>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>PREG_SPLIT_DELIM_CAPTURE</term>
<listitem>
<simpara>
If this flag is set, parenthesized expression in the delimiter pattern
will be captured and returned as well. This flag was added for 4.0.5.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</para>
<para>
<example>
<title><function>preg_split</function> example : Get the parts of a search string.</title>
<programlisting role="php">
<![CDATA[
// split the phrase by any number of commas or space characters,
// which include " ", \r, \t, \n and \f
$keywords = preg_split ("/[\s,]+/", "hypertext language, programming");
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>Splitting a string into component characters.</title>
<programlisting role="php">
<![CDATA[
$str = 'string';
$chars = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY);
print_r($chars);
]]>
</programlisting>
</example>
</para>
<para>
See also
<function>spliti</function>,
<function>split</function>,
<function>implode</function>,
<function>preg_match</function>,
<function>preg_match_all</function>, and
<function>preg_replace</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
-->