difference between soundex and metaphone in php?

Posted on Updated on

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.

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
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s