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

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

soundex(string $string): string

Parameters

ParameterDescription
string The input string.

Return value

A key such as R163, or "" for an empty string.

Examples

Similar-sounding namesTry it yourself
<?php
echo soundex("Robert"), " ", soundex("Rupert"), "\n";
echo soundex("Smith"), " ", soundex("Smyth"), "\n";

Output

R163 R163
S530 S530
The first letter must matchTry it yourself
<?php
var_dump(soundex("Catherine") === soundex("Kathryn"));

Output

bool(false)

Version history

VersionChange
PHP 4.0Added

Was this page helpful?