<?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.metaphone.php',
    1 => 'metaphone',
    2 => '文字列の metaphone キーを計算する',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'String 関数',
  ),
  'prev' => 
  array (
    0 => 'function.md5-file.php',
    1 => 'md5_file',
  ),
  'next' => 
  array (
    0 => 'function.money-format.php',
    1 => 'money_format',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/strings/functions/metaphone.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.metaphone" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">metaphone</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">metaphone</span> &mdash; <span class="dc-title">文字列の metaphone キーを計算する</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.metaphone-description">
  <h3 class="title">説明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>metaphone</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$string</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$max_phonemes</code><span class="initializer"> = 0</span></span>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="para rdfs-comment">
   <code class="parameter">string</code> の metaphone キーを計算します。
  </p>
  <p class="para">
   <span class="function"><a href="function.soundex.php" class="function">soundex()</a></span> と同様に metaphone は、
   発音が似た単語について同じキーを作成します。metaphone は、
   英語の発音の基本的ルールを知っているので、
   <span class="function"><a href="function.soundex.php" class="function">soundex()</a></span> よりも正確です。
   metaphone が生成するキーは可変長です。
  </p>
  <p class="para">
   metaphone は、Lawrence Philips &lt;lphilips at verity dot com&gt; により
   開発されました。[&quot;Practical
   Algorithms for Programmers&quot;, Binstock &amp; Rex, Addison Wesley,
   1995] で解説されています。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.metaphone-parameters">
  <h3 class="title">パラメータ</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       入力文字列。
      </p>
     </dd>
    
    
     <dt><code class="parameter">max_phonemes</code></dt>
     <dd>
      <p class="para">
       このパラメータは、返される metaphone キーの長さを最大
       <code class="parameter">max_phonemes</code> <em>文字</em> までに制限します。
       しかし、phonemes は完全に書き換えられるので、
       結果の文字列の長さは、<code class="parameter">max_phonemes</code> よりも少し長くなります。
       デフォルト値の <code class="literal">0</code> は、無制限であることを意味します。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.metaphone-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="para">
   metaphone キーを文字列で返します。
  </p>
 </div>


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

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       この関数は、失敗時に <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> を返さなくなりました。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.metaphone-examples">
  <h3 class="title">例</h3>
  <p class="para">
   <div class="example" id="metaphone.example.basic">
    <p><strong>例1 <span class="function"><strong>metaphone()</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 />var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">metaphone</span><span style="color: #007700">(</span><span style="color: #DD0000">'programming'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">metaphone</span><span style="color: #007700">(</span><span style="color: #DD0000">'programmer'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>上の例の出力は以下となります。</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">string(7) &quot;PRKRMNK&quot;
string(6) &quot;PRKRMR&quot;</pre>
</div>
    </div>
   </div>
  </p>
  <p class="para">
   <div class="example" id="metaphone.example.phonemes">
    <p><strong>例2 <code class="parameter">phonemes</code> パラメータの使用例</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">metaphone</span><span style="color: #007700">(</span><span style="color: #DD0000">'programming'</span><span style="color: #007700">, </span><span style="color: #0000BB">5</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">metaphone</span><span style="color: #007700">(</span><span style="color: #DD0000">'programmer'</span><span style="color: #007700">, </span><span style="color: #0000BB">5</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>上の例の出力は以下となります。</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">string(5) &quot;PRKRM&quot;
string(5) &quot;PRKRM&quot;</pre>
</div>
    </div>
   </div>
  </p>
  <p class="para">
   <div class="example" id="metaphone.example.phonemes-overlong">
    <p><strong>例3 <code class="parameter">phonemes</code> 引数を使う</strong></p>
    <div class="example-contents"><p>
     この例では、
     <span class="function"><strong>metaphone()</strong></span> 関数は5文字の文字列を生成するように指定されていますが、
     最後の音素を分割する必要がある
     (<code class="literal">&#039;x&#039;</code> は <code class="literal">&#039;KS&#039;</code> に書き換えられるとします),
     ため、返される文字列は6文字になります。
    </p></div>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">metaphone</span><span style="color: #007700">(</span><span style="color: #DD0000">'Asterix'</span><span style="color: #007700">, </span><span style="color: #0000BB">5</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>上の例の出力は以下となります。</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">string(6) &quot;ASTRKS&quot;</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.metaphone-seealso">
  <h3 class="title">参考</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.levenshtein.php" class="function" rel="rdfs-seeAlso">levenshtein()</a> - 二つの文字列のレーベンシュタイン距離を計算する</span></li>
    <li><span class="function"><a href="function.similar-text.php" class="function" rel="rdfs-seeAlso">similar_text()</a> - 二つの文字列の間の類似性を計算する</span></li>
    <li><span class="function"><a href="function.soundex.php" class="function" rel="rdfs-seeAlso">soundex()</a> - 文字列の soundex キーを計算する</span></li>
   </ul>
  </p>
 </div>

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