mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-19 10:28:54 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@297028 c90b9560-bf6c-de11-be94-00142212c4b1
205 lines
4.9 KiB
XML
205 lines
4.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.rtrim">
|
|
<refnamediv>
|
|
<refname>rtrim</refname>
|
|
<refpurpose>Strip whitespace (or other characters) from the end of a string</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>rtrim</methodname>
|
|
<methodparam><type>string</type><parameter>str</parameter></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>charlist</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
This function returns a string with whitespace stripped from the
|
|
end of <parameter>str</parameter>.
|
|
</para>
|
|
<para>
|
|
Without the second parameter,
|
|
<function>rtrim</function> will strip these characters:
|
|
<!-- sorted by importance. Printed 3 times: trim, ltrim, rtrim -->
|
|
<itemizedlist>
|
|
<listitem>
|
|
<simpara>
|
|
" " (<acronym>ASCII</acronym> <literal>32</literal>
|
|
(<literal>0x20</literal>)), an ordinary space.
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
"\t" (<acronym>ASCII</acronym> <literal>9</literal>
|
|
(<literal>0x09</literal>)), a tab.
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
"\n" (<acronym>ASCII</acronym> <literal>10</literal>
|
|
(<literal>0x0A</literal>)), a new line (line feed).
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
"\r" (<acronym>ASCII</acronym> <literal>13</literal>
|
|
(<literal>0x0D</literal>)), a carriage return.
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
"\0" (<acronym>ASCII</acronym> <literal>0</literal>
|
|
(<literal>0x00</literal>)), the <literal>NUL</literal>-byte.
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara> <!-- not \v, since not supported by PHP -->
|
|
"\x0B" (<acronym>ASCII</acronym> <literal>11</literal>
|
|
(<literal>0x0B</literal>)), a vertical tab.
|
|
</simpara>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>str</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The input string.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>charlist</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
You can also specify the characters you want to strip, by means
|
|
of the <parameter>charlist</parameter> parameter.
|
|
Simply list all characters that you want to be stripped. With
|
|
<literal>..</literal> you can specify a range of characters.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Returns the modified string.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>4.1.0</entry>
|
|
<entry>
|
|
The <parameter>charlist</parameter> parameter was added.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Usage example of <function>rtrim</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$text = "\t\tThese are a few words :) ... ";
|
|
$binary = "\x09Example string\x0A";
|
|
$hello = "Hello World";
|
|
var_dump($text, $binary, $hello);
|
|
|
|
print "\n";
|
|
|
|
$trimmed = rtrim($text);
|
|
var_dump($trimmed);
|
|
|
|
$trimmed = rtrim($text, " \t.");
|
|
var_dump($trimmed);
|
|
|
|
$trimmed = rtrim($hello, "Hdle");
|
|
var_dump($trimmed);
|
|
|
|
// trim the ASCII control characters at the end of $binary
|
|
// (from 0 to 31 inclusive)
|
|
$clean = rtrim($binary, "\x00..\x1F");
|
|
var_dump($clean);
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
string(32) " These are a few words :) ... "
|
|
string(16) " Example string
|
|
"
|
|
string(11) "Hello World"
|
|
|
|
string(30) " These are a few words :) ..."
|
|
string(26) " These are a few words :)"
|
|
string(9) "Hello Wor"
|
|
string(15) " Example string"
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>trim</function></member>
|
|
<member><function>ltrim</function></member>
|
|
</simplelist>
|
|
</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:"~/.phpdoc/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
|
|
-->
|