svn: /phpdoc/en/trunk/reference/strings/functions/ trim.xml
| From: | Philip Olson | Date: | Mon, 09 May 2011 18:22:39 +0000 |
| Subject: | svn: /phpdoc/en/trunk/reference/strings/functions/ trim.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-8084@lists.php.net to get a copy of this message | ||
philip Mon, 09 May 2011 18:22:39 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=310860
Log:
Clarified removing middle strings via an example and note. Deals with PHP Bug #54697
Bug: http://bugs.php.net/54697 (Bogus) trim function not
giving right results
Changed paths:
U phpdoc/en/trunk/reference/strings/functions/trim.xml
Modified: phpdoc/en/trunk/reference/strings/functions/trim.xml
===================================================================
--- phpdoc/en/trunk/reference/strings/functions/trim.xml 2011-05-09 16:47:02 UTC (rev 310859)
+++ phpdoc/en/trunk/reference/strings/functions/trim.xml 2011-05-09 18:22:39 UTC (rev 310860)
@@ -144,6 +144,9 @@
$trimmed = trim($hello, "Hdle");
var_dump($trimmed);
+$trimmed = trim($hello, 'HdWr');
+var_dump($trimmed);
+
// trim the ASCII control characters at the beginning and end of $binary
// (from 0 to 31 inclusive)
$clean = trim($binary, "\x00..\x1F");
@@ -163,6 +166,7 @@
string(28) "These are a few words :) ..."
string(24) "These are a few words :)"
string(5) "o Wor"
+string(9) "ello Worl"
string(14) "Example string"
]]>
</screen>
@@ -214,12 +218,27 @@
</para>
</refsect1>
+ <refsect1 role="notes">
+ &reftitle.notes;
+ <note>
+ <title>Possible gotcha: removing middle characters</title>
+ <para>
+ Because <function>trim</function> trims characters from the beginning and end of
+ a <type>string</type>, it may be confusing when characters are (or are not) removed
from
+ the middle. <literal>trim('abc', 'bad')</literal> removes both
'a' and 'b' because it
+ trims 'a' thus moving 'b' to the beginning to also be trimmed. So, this is
why it "works"
+ whereas <literal>trim('abc', 'b')</literal> seemingly does not.
+ </para>
+ </note>
+ </refsect1>
+
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>ltrim</function></member>
<member><function>rtrim</function></member>
+ <member><function>str_replace</function></member>
</simplelist>
</para>
</refsect1>