array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'uk', ), 'this' => array ( 0 => 'function.soundex.php', 1 => 'soundex', 2 => 'Calculate the soundex key of a string', ), 'up' => array ( 0 => 'ref.strings.php', 1 => 'String Функції', ), '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); ?>

soundex

(PHP 4, PHP 5, PHP 7, PHP 8)

soundexCalculate the soundex key of a string

Опис

soundex(string $string): string

Calculates the soundex key of string.

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.

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.

Параметри

string

The input string.

Значення, що повертаються

Returns the soundex key as a string with four characters. If at least one letter is contained in string, the returned string starts with a letter. Otherwise "0000" is returned.

Журнал змін

Версія Опис
8.0.0 Prior to this version, calling the function with an empty string returned false for no particular reason.

Приклади

Приклад #1 Soundex Examples

<?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
?>

Прогляньте також