soundex

PHP 4, PHP 5, PHP 7, PHP 8
soundex - Calculate 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.

Parameters

string

The input string.

Return Values

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.

Changelog

Version Description
8.0.0 Prior to this version, calling the function with an empty string returned false for no particular reason.

Related Functions

Example of soundex

Show all examples for soundex

PHP Version:


Function soundex:

Strings Functions

Most used PHP functions