Fix #60314: Metaphone returns fewer phonemes than defined

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@351215 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Christoph Michael Becker 2020-11-04 10:08:57 +00:00
parent 8bdab424de
commit ef05457faa

View file

@ -47,7 +47,9 @@
<listitem>
<para>
This parameter restricts the returned metaphone key to
<parameter>phonemes</parameter> characters in length.
<parameter>phonemes</parameter> <emphasis>characters</emphasis> in length.
However, the resulting phonemes are always transcribed completely, so the
resulting string length may be slightly longer than <parameter>phonemes</parameter>.
The default value of <literal>0</literal> means no restriction.
</para>
</listitem>
@ -76,7 +78,7 @@ var_dump(metaphone('programmer'));
?>
]]>
</programlisting>
&example.outputs.similar;
&example.outputs;
<screen>
<![CDATA[
string(7) "PRKRMNK"
@ -96,7 +98,7 @@ var_dump(metaphone('programmer', 5));
?>
]]>
</programlisting>
&example.outputs.similar;
&example.outputs;
<screen>
<![CDATA[
string(5) "PRKRM"
@ -105,6 +107,30 @@ string(5) "PRKRM"
</screen>
</example><!-- }}} -->
</para>
<para>
<example xml:id="metaphone.example.phonemes-overlong">
<title>Using the <parameter>phonemes</parameter> parameter</title>
<simpara>
In this example, <function>metaphone</function> is advised to produce a string
of five characters, but that would require to split the final phoneme
(<literal>'x'</literal> is supposed to be transcribed to <literal>'KS'</literal>),
so the function returns a string with six characters.
</simpara>
<programlisting role="php">
<![CDATA[
<?php
var_dump(metaphone('Asterix', 5));
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
string(6) "ASTRKS"
]]>
</screen>
</example>
</para>
</refsect1><!-- }}} -->
</refentry>