<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.strings.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ja',
  ),
  'this' => 
  array (
    0 => 'function.str-ireplace.php',
    1 => 'str_ireplace',
    2 => '大文字小文字を区別しない str_replace',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'String 関数',
  ),
  'prev' => 
  array (
    0 => 'function.str-increment.php',
    1 => 'str_increment',
  ),
  'next' => 
  array (
    0 => 'function.str-pad.php',
    1 => 'str_pad',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/strings/functions/str-ireplace.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.str-ireplace" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">str_ireplace</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">str_ireplace</span> &mdash; <span class="dc-title">大文字小文字を区別しない <span class="function"><a href="function.str-replace.php" class="function">str_replace()</a></span></span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.str-ireplace-description">
  <h3 class="title">説明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>str_ireplace</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$search</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$replace</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.array.php" class="type array">array</a></span></span> <code class="parameter">$subject</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter reference">&$count</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span><br>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.array.php" class="type array">array</a></span></span></div>

  <p class="para rdfs-comment">
   この関数は、<code class="parameter">subject</code> の中に現れるすべての
   <code class="parameter">search</code>(大文字小文字を区別しない)を
   <code class="parameter">replace</code> に置き換えた文字列あるいは配列を返します。
  </p>
   <p class="para">
    固定の文字列ではなく、パターンベースでテキストを置換したい場合、
    <span class="function"><a href="function.preg-replace.php" class="function">preg_replace()</a></span> 関数を
    <a href="reference.pcre.pattern.modifiers.php" class="link">パターン修飾子</a> <code class="literal">i</code> と一緒に使ってください。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.str-ireplace-parameters">
  <h3 class="title">パラメータ</h3>
  <p class="para">
   <code class="parameter">search</code> および
   <code class="parameter">replace</code> が配列の場合は、
   <span class="function"><strong>str_ireplace()</strong></span> はそれぞれの配列から取り出した
   値を使用して <code class="parameter">subject</code> の置換を行います。
   <code class="parameter">replace</code> の要素数が
   <code class="parameter">search</code> より少ない場合は、残りの要素は
   空の文字列に置き換えられます。もし <code class="parameter">search</code>
   が配列で <code class="parameter">replace</code> が文字列だった場合は
   すべての <code class="parameter">search</code> が同じ文字列に置き換えられます。
   しかし、逆は意味がありません。
  </p>
  <p class="para">
   <code class="parameter">search</code> あるいは <code class="parameter">replace</code>
   が配列の場合は、配列の最初の要素から順に処理されます。
  </p>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">search</code></dt>
     <dd>
      <p class="para">
       探したい値。<em>needle (針)</em> と呼ばれることもあります。
       配列を使えば、複数の値を指定することもできます。
      </p>
     </dd>
    
    
     <dt><code class="parameter">replace</code></dt>
     <dd>
      <p class="para">
       見つかった <code class="parameter">search</code> を置き換える値。
       配列を使えば、複数の値を指定することもできます。
      </p>
     </dd>
    
    
     <dt><code class="parameter">subject</code></dt>
     <dd>
      <p class="para">
       検索・置換の対象となる文字列あるいは配列。
       <em>haystack (干し草の山)</em> と呼ばれることもあります。
      </p>
      <p class="para">
       <code class="parameter">subject</code> が配列の場合は、そのすべての要素に
       対して検索と置換が行われ、返される結果も配列となります。
      </p>
     </dd>
    
    
     <dt><code class="parameter">count</code></dt>
     <dd>
      <p class="para">
       指定した場合は、マッチして置換が行われた箇所の個数がここに格納されます。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.str-ireplace-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="para">
   置換した文字列あるいは配列を返します。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.str-ireplace-changelog">
  <h3 class="title">変更履歴</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>バージョン</th>
      <th>説明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     
 <tr>
  <td>8.2.0</td>
  <td>
   ケースフォールディングは、<span class="function"><a href="function.setlocale.php" class="function">setlocale()</a></span>
   で設定されたロケールに依存しなくなりました。
   ASCII のケースフォールディングのみが行われます。
   ASCII でないバイト列は、バイト値として比較されます。
  </td>
 </tr>


    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.str-ireplace-examples">
  <h3 class="title">例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>例1 <span class="function"><strong>str_ireplace()</strong></span> の例</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$bodytag </span><span style="color: #007700">= </span><span style="color: #0000BB">str_ireplace</span><span style="color: #007700">(</span><span style="color: #DD0000">"%body%"</span><span style="color: #007700">, </span><span style="color: #DD0000">"black"</span><span style="color: #007700">, </span><span style="color: #DD0000">"&lt;body text=%BODY%&gt;"</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$bodytag</span><span style="color: #007700">; </span><span style="color: #FF8000">// &lt;body text=black&gt;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.str-ireplace-notes">
  <h3 class="title">注意</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: <span class="simpara">この関数はバイナリデータに対応しています。
</span></p></blockquote>
  <div class="caution"><strong class="caution">警告</strong>
   <h1 class="title">置換の順番に関するメモ</h1>
   <p class="para">
    <span class="function"><strong>str_ireplace()</strong></span> は左から右へと置換を行うので、
    複数の置換を行うときには、前に追加された値を置換する可能性もあります。
    <span class="function"><a href="function.str-replace.php" class="function">str_replace()</a></span> のドキュメントにある
    2 番目の例が、これが及ぼす影響の実例です。
   </p>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.str-ireplace-seealso">
  <h3 class="title">参考</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.str-replace.php" class="function" rel="rdfs-seeAlso">str_replace()</a> - 検索文字列に一致したすべての文字列を置換する</span></li>
    <li><span class="function"><a href="function.preg-replace.php" class="function" rel="rdfs-seeAlso">preg_replace()</a> - 正規表現検索および置換を行う</span></li>
    <li><span class="function"><a href="function.strtr.php" class="function" rel="rdfs-seeAlso">strtr()</a> - 文字の変換あるいは部分文字列の置換を行う</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>