soundex
Returns the sound code of an English word.
Syntax
soundex(string $string): stringParameters
| Parameter | Type | Description |
|---|---|---|
| $string | string | A word. |
Return value
stringA code of a letter and three digits.
Examples
Words that sound alike:
<?php
echo soundex('Robert'), ' ', soundex('Rupert'), "\n";
var_dump(soundex('Smith') === soundex('Smyth'));Output:
R163 R163
bool(true)Notes
The algorithm is designed for English. The similar metaphone() function reflects pronunciation more precisely.
See also
- levenshtein — Counts how many edits turn one string into another.
- similar_text — Calculates how similar two strings are.
In the tutorial
- Strings — Working with strings in PHP — quotes, concatenation, length, searching, replacing and multibyte functions.