CancelImage Upload

PHP Function comparisson: soundex() vs. metaphone()

In a previous tutorial I have discussed the PHP function soundex(), and how it produces a 4 digit code that can be used to compare words that sound alike, but are spelt differently (such as Weather and Whether).

And while soundex() is a very useful function, PHP offers a more exact alternative for the English language: metaphone(). The main difference being that metaphone() has mastered some of the basic rules of the English Language.

Note however that metaphone() should only be used on English words. It will not be of much use for instance with French, German, Italian or Spanish. Here is an example. Note that while soundex() returns the same code for Weather and Whether, metaphone() can indeed tell a slight difference:

<?php

echo soundex("Weather");

echo "<br>";

echo soundex("Whether");

echo "<br>";

echo metaphone("Weather");

echo "<br>";

echo metaphone("Whether");

?>

The result:

W360
W360
W0R
H0R

The example illustrates two things. First that soundex() and metaphone() codes cannot be compared. Second that metaphone() is the more fine tuned of the two. Soundex() might still provide a better solution however regarding the suggestion of alternative keywords in search engines.

Login
Want to leave a comment?

No problem. Just enter your email and password below.


register | home | reminder

myDesignTool Networking • www.mydesigntool.cominfo@mydesigntool.com