mirror of
https://github.com/php/doc-ja.git
synced 2026-04-26 09:28:10 +02:00
3a287886ae
git-svn-id: https://svn.php.net/repository/phpdoc/ja/trunk@189347 c90b9560-bf6c-de11-be94-00142212c4b1
103 lines
3.4 KiB
XML
103 lines
3.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision: 1.5 $ -->
|
|
<!-- splitted from ./ja/functions/strings.xml, last change in rev 1.1 -->
|
|
<!-- EN-Revision: 1.5 Maintainer: hirokawa Status: ready -->
|
|
<!-- CREDITS: shimooka -->
|
|
<refentry id="function.strtr">
|
|
<refnamediv>
|
|
<refname>strtr</refname>
|
|
<refpurpose>特定の文字を変換する</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>説明</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>
|
|
この関数は <parameter>str</parameter> を走査し、
|
|
<parameter>from</parameter> に含まれる文字が見つかると、そのすべてを
|
|
<parameter>to</parameter> の中で対応する文字に置き換え、
|
|
その結果を返します。
|
|
</para>
|
|
<para>
|
|
<parameter>from</parameter> と <parameter>to</parameter> の
|
|
長さが異なる場合、長い方の余分な文字は無視されます。
|
|
<example>
|
|
<title><function>strtr</function>の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$addr = strtr($addr, "äåö", "aao");
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<function>strtr</function> は、引数を2つ指定してコールすることが可能です。
|
|
引数を2つ指定してコールっ_場合、異なった動作となります。
|
|
文字列<parameter>from</parameter> では、ソース文字列で変換を行う
|
|
「文字列 -> 文字列」の組を指定する必要があります。
|
|
<function>strtr</function> は、常にまず最も長くマッチする文字列を探し、
|
|
既に置換されている部分文字列については再度置換を行いません。
|
|
</para>
|
|
<example>
|
|
<title>2 つの引数を伴う <function>strtr</function> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$trans = array("hello" => "hi", "hi" => "hello");
|
|
echo strtr("hi all, I said hello", $trans);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
これは次を出力します:
|
|
</para>
|
|
<screen>
|
|
<![CDATA[
|
|
hello all, I said hi
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
<note>
|
|
<simpara>
|
|
このオプションのパラメータ<parameter>to</parameter>および
|
|
<parameter>from</parameter>は、PHP 4.0.0 で追加されました。
|
|
</simpara>
|
|
</note>
|
|
<para>
|
|
<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
|
|
-->
|