1
0
mirror of https://github.com/php/doc-en.git synced 2026-04-30 02:33:15 +02:00
Files
archived-doc-en/reference/strings/functions/soundex.xml
AllenJB 873f4a3d50 String comparison / similarity doc improvements (#4647)
* strcmp: Improve behavior description and direct users to alternative functions (strcoll and Collator::compare) where appropriate;
Add the "similarity" functions to seealso
Removed substr from seealso (why is it here?)

* Cross-link all the string similarity functions

* Trailing whitespace removal

* Update reference/strings/functions/strcmp.xml

Co-authored-by: Kamil Tekiela <tekiela246@gmail.com>

* strcmp: Improve behavior description and direct users to alternative functions (strcoll and Collator::compare) where appropriate

---------

Co-authored-by: Kamil Tekiela <tekiela246@gmail.com>
2025-10-03 09:47:29 -05:00

134 lines
3.4 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.soundex" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>soundex</refname>
<refpurpose>Calculate the soundex key of a string</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>soundex</methodname>
<methodparam><type>string</type><parameter>string</parameter></methodparam>
</methodsynopsis>
<para>
Calculates the soundex key of <parameter>string</parameter>.
</para>
<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.
</para>
<para>
This particular soundex function is one described by Donald Knuth
in "The Art Of Computer Programming, vol. 3: Sorting And
Searching", Addison-Wesley (1973), pp. 391-392.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>string</parameter></term>
<listitem>
<para>
The input string.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the soundex key as a &string; with four characters.
If at least one letter is contained in <parameter>string</parameter>, the returned
string starts with a letter. Otherwise <literal>"0000"</literal> is returned.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.0.0</entry>
<entry>
Prior to this version, calling the function with an empty string returned &false;
for no particular reason.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Soundex Examples</title>
<programlisting role="php">
<![CDATA[
<?php
echo soundex("Euler"), PHP_EOL, soundex("Ellery"), PHP_EOL;
soundex("Euler") == soundex("Ellery"); // E460
soundex("Gauss") == soundex("Ghosh"); // G200
soundex("Hilbert") == soundex("Heilbronn"); // H416
soundex("Knuth") == soundex("Kant"); // K530
soundex("Lloyd") == soundex("Ladd"); // L300
soundex("Lukasiewicz") == soundex("Lissajous"); // L222
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>levenshtein</function></member>
<member><function>metaphone</function></member>
<member><function>similar_text</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->