nlopess Wed Aug 11 12:19:15 2004 EDT
Modified files:
/phpdoc/en/reference/strings/functions explode.xml
Log:
document new PHP 5.1 feature: negative limit
http://cvs.php.net/diff.php/phpdoc/en/reference/strings/functions/explode.xml?r1=1.7&r2=1.8&ty=u
Index: phpdoc/en/reference/strings/functions/explode.xml
diff -u phpdoc/en/reference/strings/functions/explode.xml:1.7
phpdoc/en/reference/strings/functions/explode.xml:1.8
--- phpdoc/en/reference/strings/functions/explode.xml:1.7 Thu Jul 22 18:51:12
2004
+++ phpdoc/en/reference/strings/functions/explode.xml Wed Aug 11 12:19:15 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.7 $ -->
+<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
<refentry id="function.explode">
<refnamediv>
@@ -31,6 +31,11 @@
return an array containing <parameter>string</parameter>.
</para>
<para>
+ If the <parameter>limit</parameter> parameter is negative, all components
+ except the last <parameter>limit</parameter> are returned. This feature
+ was added in PHP 5.1.0.
+ </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
@@ -64,6 +69,42 @@
?>
]]>
</programlisting>
+ </example>
+ </para>
+ <para>
+ <example>
+ <title><parameter>limit</parameter> parameter examples</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$str = 'one|two|three|four';
+
+// positive limit
+print_r(explode('|', $str, 2));
+
+// negative limit
+print_r(explode('|', $str, -1));
+?>
+]]>
+ </programlisting>
+ <para>
+ The above example will output:
+ </para>
+ <screen>
+<![CDATA[
+Array
+(
+ [0] => one
+ [1] => two|three|four
+)
+Array
+(
+ [0] => one
+ [1] => two
+ [2] => three
+)
+]]>
+ </screen>
</example>
</para>