Files
doc-fr/reference/strings/functions/strtr.xml
Damien Seguy d8a7dfa99c synch with en
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@278208 c90b9560-bf6c-de11-be94-00142212c4b1
2009-04-03 12:06:19 +00:00

188 lines
5.0 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.21 $ -->
<!-- EN-Revision: 1.9 Maintainer: yannick Status: ready -->
<!-- Reviewed: yes -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.strtr" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>strtr</refname>
<refpurpose>Remplace des caractères dans une chaîne</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>strtr</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam><type>string</type><parameter>from</parameter></methodparam>
<methodparam><type>string</type><parameter>to</parameter></methodparam>
</methodsynopsis>
<methodsynopsis>
<type>string</type><methodname>strtr</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam><type>array</type><parameter>replace_pairs</parameter></methodparam>
</methodsynopsis>
<para>
<function>strtr</function> retourne la chaîne <parameter>str</parameter>,
après avoir remplacé chaque caractère du paramètre
<parameter>from</parameter> par son équivalent dans le paramètre
<parameter>to</parameter>.
</para>
<para>
Si <parameter>from</parameter> et <parameter>to</parameter> sont de
tailles différentes, les caractères en trop dans l'un ou l'autre
seront ignorés.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>str</parameter></term>
<listitem>
<para>
La chaîne à traiter.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>from</parameter></term>
<listitem>
<para>
Les caractères de départ.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>to</parameter></term>
<listitem>
<para>
Les caractères de remplacement.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>replace_pairs</parameter></term>
<listitem>
<para>
Le paramètre <parameter>replace_pairs</parameter> peut être utilisé
comme substitue à <parameter>to</parameter> et <parameter>from</parameter>
et dans ce cas, ce sera un tableau sous la forme
<literal>array('from' => 'to', ...)</literal>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Retourne une copie de la chaîne <parameter>str</parameter>,
dont toutes les occurrences de chaque caractère de
<parameter>from</parameter> ont été remplacées par les
caractères de <parameter>to</parameter> correspondant.
</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.0.0</entry>
<entry>
Ajout des paramètres optionnels <parameter>to</parameter> et
<parameter>from</parameter>.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Exemple avec <function>strtr</function></title>
<programlisting role="php">
<![CDATA[
<?php
$addr = strtr($addr, "äåö", "aao");
?>
]]>
</programlisting>
</example>
</para>
<para>
<function>strtr</function> peut être appelée avec uniquement
deux arguments. Dans ce cas, elle se comporte d'une autre
façon : <parameter>from</parameter> doit alors être un tableau
associatif de paires, qui seront remplacées
dans la chaîne <parameter>str</parameter>. <function>strtr</function>
commence toujours par rechercher la chaîne la plus longue,
et ne travaille pas sur des segments qu'elle a déjà modifié.
</para>
<example>
<title>Exemple avec <function>strtr</function> et 2 arguments</title>
<programlisting role="php">
<![CDATA[
<?php
$trans = array("hello" => "hi", "hi" => "hello");
echo strtr("hi all, I said hello", $trans);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
hello all, I said hi
]]>
</screen>
</example>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>preg_replace</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
-->