mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-30 04:42:24 +02:00
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@158568 c90b9560-bf6c-de11-be94-00142212c4b1
105 lines
3.2 KiB
XML
105 lines
3.2 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.13 $ -->
|
|
<!-- EN-Revision: 1.5 Maintainer: didou Status: ready -->
|
|
<refentry id="function.strtr">
|
|
<refnamediv>
|
|
<refname>strtr</refname>
|
|
<refpurpose>Remplace des caractères dans une chaîne</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<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.
|
|
<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>
|
|
<para>
|
|
<example>
|
|
<title>Exemple de <function>strtr</function> avec deux arguments</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$trans = array("bonjour" => "salut", "salut" => "bonjour");
|
|
echo strtr("salut à tous, j'ai dit bonjour", $trans);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
bonjour à tous, j'ai dit salut
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<note>
|
|
<simpara>
|
|
Les paramètres optionnels <parameter>to</parameter> et
|
|
<parameter>from</parameter> ont été ajoutés en
|
|
&php; 4.0.0.
|
|
</simpara>
|
|
</note>
|
|
<para>
|
|
Voir aussi
|
|
<function>ereg_replace</function>.
|
|
</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
|
|
-->
|