PHP 8 reference · String Functions
PHP soundex() Function
Return a four-character code for how an English word sounds, so names like Robert and Rupert can be matched.
PHP 8 Since 4.0
Syntax
soundex(string $string): string
Parameters
| Parameter | Description |
|---|---|
string |
The input string. |
Return value
A key such as R163, or "" for an empty string.
Examples
<?php
echo soundex("Robert"), " ", soundex("Rupert"), "\n";
echo soundex("Smith"), " ", soundex("Smyth"), "\n";
Output
R163 R163 S530 S530
<?php
var_dump(soundex("Catherine") === soundex("Kathryn"));
Output
bool(false)
Version history
| Version | Change |
|---|---|
| PHP 4.0 | Added |
Related
levenshtein()· Calculate the edit distance between two strings: the fewest insertions, deletions and replacements to turn one into the other.similar_text()· Calculate how similar two strings are, as a count of matching characters and optionally as a percentage.- PHP Strings · tutorial