mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-04-29 03:33:21 +02:00
34b976e4c6
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@197283 c90b9560-bf6c-de11-be94-00142212c4b1
225 lines
5.5 KiB
XML
225 lines
5.5 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.18 $ -->
|
|
<!-- EN-Revision: 1.10 Maintainer: jsgoupil Status: ready -->
|
|
<!-- Reviewed: yes -->
|
|
<refentry id="function.trim">
|
|
<refnamediv>
|
|
<refname>trim</refname>
|
|
<refpurpose>
|
|
Supprime les espaces (ou d'autres caractères) en début et fin de chaîne
|
|
</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>trim</methodname>
|
|
<methodparam><type>string</type><parameter>str</parameter></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>charlist</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>trim</function> retourne la chaîne <parameter>str</parameter>, après
|
|
avoir supprimé les caractères invisibles en début et fin de chaîne.
|
|
Si le second paramètre <parameter>charlist</parameter> est omis,
|
|
<function>trim</function> supprimera les caractères suivants :
|
|
<!-- sorted by importance. Printed 3 times: trim, ltrim, rtrim -->
|
|
<itemizedlist>
|
|
<listitem>
|
|
<simpara>
|
|
"<literal> </literal>" (<acronym>ASCII</acronym> <literal>32</literal>
|
|
(<literal>0x20</literal>)), un espace ordinaire.
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
"<literal>\t</literal>" (<acronym>ASCII</acronym> <literal>9</literal>
|
|
(<literal>0x09</literal>)), une tabulation.
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
"<literal>\n</literal>" (<acronym>ASCII</acronym> <literal>10</literal>
|
|
(<literal>0x0A</literal>)), une nouvelle ligne (<literal>line feed</literal>).
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
"<literal>\r</literal>" (<acronym>ASCII</acronym> <literal>13</literal>
|
|
(<literal>0x0D</literal>)), un retour chariot (<literal>carriage return</literal>).
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
"<literal>\0</literal>" (<acronym>ASCII</acronym> &zero;
|
|
(<literal>0x00</literal>)), le caractère <literal>NUL</literal>.
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara> <!-- not \v, since not supported by PHP -->
|
|
"\x0B" (<acronym>ASCII</acronym> <literal>11</literal>
|
|
(<literal>0x0B</literal>)), une tabulation verticale.
|
|
</simpara>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>str</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
La &string; qui sera coupé.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>charlist</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Optionnellement, les caractères supprimés peuvent aussi être spécifiés
|
|
en utilisant le paramètre <parameter>charlist</parameter>. Listez
|
|
simplement tous les caractères que vous voulez supprimer. Avec
|
|
<literal>..</literal> vous pouvez spécifier une plage de caractères.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
La chaîne de caractères coupée.
|
|
</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>
|
|
Le paramètre optionnel <parameter>charlist</parameter> a été ajouté.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Exemple avec <function>trim</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$text = "\t\tVoici quelques mots :) ... ";
|
|
|
|
echo trim($text); // "Voici quelques mots :) ..."
|
|
echo trim($text, " \t."); // "Voici quelques mots :)"
|
|
|
|
// supprime tous les caractères de contrôle ASCII au début de la chaîne de caractères.
|
|
// (de 0 à 31 inclus)
|
|
$clean = trim($binary, "\x00..\x1F");
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Suppression de caractères dans un tableau avec <function>trim</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
function trim_value(&$value)
|
|
{
|
|
$value = trim($value);
|
|
}
|
|
|
|
$fruit = array('pomme','banane ', ' canneberge ');
|
|
var_dump($fruit);
|
|
|
|
array_walk($fruit, 'trim_value');
|
|
var_dump($fruit);
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
array(3) {
|
|
[0]=>
|
|
string(5) "pomme"
|
|
[1]=>
|
|
string(7) "banane "
|
|
[2]=>
|
|
string(11) " canneberge "
|
|
}
|
|
array(3) {
|
|
[0]=>
|
|
string(5) "pomme"
|
|
[1]=>
|
|
string(6) "banane"
|
|
[2]=>
|
|
string(9) "canneberge"
|
|
}
|
|
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>ltrim</function></member>
|
|
<member><function>rtrim</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:"../../../../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
|
|
-->
|