<?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 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.soundex.php',
    1 => 'soundex',
    2 => 'Calculate the soundex key of a string',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => '字符串 函数',
  ),
  'prev' => 
  array (
    0 => 'function.similar-text.php',
    1 => 'similar_text',
  ),
  'next' => 
  array (
    0 => 'function.sprintf.php',
    1 => 'sprintf',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/strings/functions/soundex.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.soundex" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">soundex</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">soundex</span> &mdash; <span class="dc-title">Calculate the soundex key of a string</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.soundex-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>soundex</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="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="para rdfs-comment">
   Calculates the soundex key of <code class="parameter">string</code>.
  </p>
  <p class="para">
   Soundex keys have the property that words pronounced similarly
   produce the same soundex key, and can thus be used to simplify
   searches in databases where you know the pronunciation but not
   the spelling.
  </p>
  <p class="para">
   This particular soundex function is one described by Donald Knuth
   in &quot;The Art Of Computer Programming, vol. 3: Sorting And
   Searching&quot;, Addison-Wesley (1973), pp. 391-392.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.soundex-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       The input string.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.soundex-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the soundex key as a <span class="type"><a href="language.types.string.php" class="type string">string</a></span> with four characters.
   If at least one letter is contained in <code class="parameter">string</code>, the returned
   string starts with a letter. Otherwise <code class="literal">&quot;0000&quot;</code> is returned.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.soundex-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>
       Prior to this version, calling the function with an empty string returned <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>
       for no particular reason.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.soundex-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 Soundex Examples</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Euler"</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">, </span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Ellery"</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Euler"</span><span style="color: #007700">)       == </span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Ellery"</span><span style="color: #007700">);    </span><span style="color: #FF8000">// E460<br /></span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Gauss"</span><span style="color: #007700">)       == </span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Ghosh"</span><span style="color: #007700">);     </span><span style="color: #FF8000">// G200<br /></span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Hilbert"</span><span style="color: #007700">)     == </span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Heilbronn"</span><span style="color: #007700">); </span><span style="color: #FF8000">// H416<br /></span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Knuth"</span><span style="color: #007700">)       == </span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Kant"</span><span style="color: #007700">);      </span><span style="color: #FF8000">// K530<br /></span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Lloyd"</span><span style="color: #007700">)       == </span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Ladd"</span><span style="color: #007700">);      </span><span style="color: #FF8000">// L300<br /></span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Lukasiewicz"</span><span style="color: #007700">) == </span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Lissajous"</span><span style="color: #007700">); </span><span style="color: #FF8000">// L222<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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


 <div class="refsect1 seealso" id="refsect1-function.soundex-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> - 计算两个字符串之间的 Levenshtein 距离</span></li>
    <li><span class="function"><a href="function.metaphone.php" class="function" rel="rdfs-seeAlso">metaphone()</a> - Calculate the metaphone key of a string</span></li>
    <li><span class="function"><a href="function.similar-text.php" class="function" rel="rdfs-seeAlso">similar_text()</a> - 计算两个字符串的相似度</span></li>
   </ul>
  </p>
 </div>


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