cvs: phpdoc /en/reference/pcre/functions preg-split.xml

From: Date: Thu, 23 May 2002 19:34:18 +0000
Subject: cvs: phpdoc /en/reference/pcre/functions preg-split.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969345780@lists.php.net to get a copy of this message
mfischer Thu May 23 15:34:18 2002 EDT Modified files: /phpdoc/en/reference/pcre/functions preg-split.xml Log: - Document the new PREG_SPLIT_OFFSET_CAPTURE flag. Index: phpdoc/en/reference/pcre/functions/preg-split.xml diff -u phpdoc/en/reference/pcre/functions/preg-split.xml:1.2 phpdoc/en/reference/pcre/functions/preg-split.xml:1.3 --- phpdoc/en/reference/pcre/functions/preg-split.xml:1.2 Wed Apr 17 02:42:49 2002 +++ phpdoc/en/reference/pcre/functions/preg-split.xml Thu May 23 15:34:18 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/pcre.xml, last change in rev 1.2 --> <refentry id="function.preg-split"> <refnamediv> @@ -57,6 +57,19 @@ </simpara> </listitem> </varlistentry> + <varlistentry> + <term>PREG_SPLIT_OFFSET_CAPTURE</term> + <listitem> + <para> + If this flag is set, for every occuring match the appendant string + offset will also be returned. Note that this changes the return + value in an array where very element is an array consisting of the + matched string at offset <literal>0</literal> and it's string offset + into <parameter>subject</parameter> at offset <literal>1</literal>. + This flag is available since 4.3.0. + </para> + </listitem> + </varlistentry> </variablelist> </para> <para> @@ -81,6 +94,46 @@ print_r($chars); ]]> </programlisting> + </example> + </para> + <para> + <example> + <title>Splitting a string into matches and their offsets.</title> + <programlisting role="php"> +<![CDATA[ +$str = 'hypertext language programming'; +$chars = preg_split('/ /', $str, -1, PREG_SPLIT_OFFSET_CAPTURE); +print_r($chars); +]]> + </programlisting> + <para> + will yield + </para> + <screen> +<![CDATA[ +Array +( + [0] => Array + ( + [0] => hypertext + [1] => 0 + ) + + [1] => Array + ( + [0] => language + [1] => 10 + ) + + [2] => Array + ( + [0] => programming + [1] => 19 + ) + +) +]]> + </screen> </example> </para> <para>

« previous php.doc (#969345780) next »