Encodera

Thanks for reading!

Donate to the site — we work hard for you.

PHP reference

soundex

Returns the sound code of an English word.

Syntax

soundex(string $string): string

Parameters

ParameterTypeDescription
$stringstringA 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.

Thanks for reading!

Donate to the site — we work hard for you.