array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'pt_BR', ), 'this' => array ( 0 => 'function.soundex.php', 1 => 'soundex', ), 'up' => array ( 0 => 'ref.strings.php', 1 => 'Funções de String', ), 'prev' => array ( 0 => 'function.similar-text.php', 1 => 'similar_text', ), 'next' => array ( 0 => 'function.sprintf.php', 1 => 'sprintf', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'pt_BR', 'path' => 'reference/strings/functions/soundex.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
soundex — Calcula a chave soundex de uma string
Calcula a chave soundex de string
.
Chaves soundex têm a propriedade de que palavras pronunciadas de forma semelhante produzem a mesma chave soundex e podem, portanto, ser usadas para simplificar pesquisas em bancos de dados onde a pronúncia é conhecida mas não a soletração.
Esta função soundex em particular é a descrita por Donald Knuth em "The Art Of Computer Programming, vol. 3: Sorting And Searching", Addison-Wesley (1973), pp. 391-392.
string
A string de entrada.
Retorna a chave soundex como uma string com quatro caracteres.
Se pelo menos uma letra estiver contida na string
, a string
retornada começa com uma letra. Caso contrário, "0000"
é retornado.
Versão | Descrição |
---|---|
8.0.0 |
Antes desta versão, chamar a função com uma string vazia retornava false
por nenhuma razão em particular.
|
Exemplo #1 Exemplos de Soundex
<?php
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
?>