uTools-Manuals/docs/php/metaphone.html
2019-04-28 19:00:34 +08:00

129 lines
5.3 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Calculate the metaphone key of a string</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.metaphone" class="refentry">
<div class="refnamediv">
<h1 class="refname">metaphone</h1>
<p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">metaphone</span> &mdash; <span class="dc-title">Calculate the metaphone key of a string</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">string</span> <code class="parameter">$str</code></span>
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$phonemes</code><span class="initializer"> = 0</span></span>
] ) : <span class="type">string</span></div>
<p class="para rdfs-comment">
Calculates the metaphone key of <code class="parameter">str</code>.
</p>
<p class="para">
Similar to <span class="function"><a href="soundex.html" class="function">soundex()</a></span> metaphone creates the same key for
similar sounding words. It&#039;s more accurate than
<span class="function"><a href="soundex.html" class="function">soundex()</a></span> as it knows the basic rules of English
pronunciation. The metaphone generated keys are of variable length.
</p>
<p class="para">
Metaphone was developed by Lawrence Philips
&lt;lphilips at verity dot com&gt;. It is described in [&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">str</code></dt>
<dd>
<p class="para">
The input string.
</p>
</dd>
<dt>
<code class="parameter">phonemes</code></dt>
<dd>
<p class="para">
This parameter restricts the returned metaphone key to
<code class="parameter">phonemes</code> characters in length.
The default value of <em>0</em> means no restriction.
</p>
</dd>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.metaphone-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
Returns the metaphone key as a string, 或者在失败时返回 <strong><code>FALSE</code></strong>.
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.metaphone-examples">
<h3 class="title">范例</h3>
<p class="para">
<div class="example" id="hex2bin.example.basic">
<p><strong>Example #1 <span class="function"><strong>metaphone()</strong></span> basic example</strong></p>
<div class="example-contents">
<div class="phpcode"><pre><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>
</pre></div>
</div>
<div class="example-contents"><p>以上例程的输出类似于:</p></div>
<div class="example-contents screen">
<div class="cdata"><pre>
string(7) &quot;PRKRMNK&quot;
string(6) &quot;PRKRMR&quot;
</pre></div>
</div>
</div>
</p>
<p class="para">
<div class="example" id="example-5923">
<p><strong>Example #2 Using the <code class="parameter">phonemes</code> parameter</strong></p>
<div class="example-contents">
<div class="phpcode"><pre><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">,&nbsp;</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">,&nbsp;</span><span style="color: #0000BB">5</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
</div>
<div class="example-contents"><p>以上例程的输出类似于:</p></div>
<div class="example-contents screen">
<div class="cdata"><pre>
string(5) &quot;PRKRM&quot;
string(5) &quot;PRKRM&quot;
</pre></div>
</div>
</div>
</p>
</div>
</div></div></div></body></html>