php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47443 metaphone('scratch') returns wrong result
Submitted: 2009-02-18 21:08 UTC Modified: 2009-02-18 22:38 UTC
From: sirokai at gmail dot com Assigned: felipe (profile)
Status: Closed Package: Strings related
PHP Version: 5.2CVS-2009-02-18 (CVS) OS: CentOS 5.2
Private report: No CVE-ID: None
 [2009-02-18 21:08 UTC] sirokai at gmail dot com
Description:
------------
When I run metaphone('scratch'), I get string(5) "SKRTX"

This is wrong. According to the rules posted for metaphone, T before CH is silent, so the result should be "SKRX". My Javascript metaphone function gets this right and I need the two to match up!

Reproduce code:
---------------
<?php 
  echo metaphone("scratch");
?>

Expected result:
----------------
SKRX

Actual result:
--------------
SKRTX

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-18 21:18 UTC] jani@php.net
Exactly what algorithm does your JS func use?
 [2009-02-18 21:29 UTC] sirokai at gmail dot com
http://code.google.com/p/yeti-witch/source/browse/trunk/lib/metaphone.js

Line 227
 [2009-02-18 22:38 UTC] felipe@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

You are right according to Lawrence Philips' Metaphone Algorithm.

Fixed in 5.3 and HEAD.

Thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 10:01:28 2024 UTC