PHP Classes
Icontem

File: index.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Johan Barbier  >  Soundex 2  >  index.php  
File: index.php
Role: Example script
Content type: text/plain
Description: example index.php page
Class: Soundex 2
Implementation of the soundex algorithm for French
 

Contents

Class file image Download
<?php
require_once 'class/php5/soundex2.cls.php';
$soundex2 = new soundex2;

$aCheck = array ('MALLEIN','MOLEINS''MOLIN''MOULIN''NAULIN''GRAU''GROS''GROSS''GROZ''GRAS''GRASS',
'ROUSSEAU''ROUSSEAUX''ROUSSOT''RASSAT''RASSSAT''ROSSAT''ROSSO'
);

$sString 'rousseau';

$soundex2 -> build ($sString);
$sSoundex $soundex2 -> sString;

foreach (
$aCheck as $clef => $val) {
    
$soundex2 -> build ($val);
    
$level levenshtein (strtolower ($sString), strtolower ($val));
    if (
$soundex2 -> sString === $sSoundex) {
        
$aWords[] = $val;
        
$aDistance[] = $level;
    }
}
array_multisort ($aDistance$aWords);
$aChecked array_combine ($aWords$aDistance);
echo 
'Soundex2 checked for ['$sString'] these entries : <br />';
echo 
'<pre>'print_r ($aChecked), '</pre>';

$aChecked $aWords $aDistance = array ();

$sString 'moulin';

$soundex2 -> build ($sString);
$sSoundex $soundex2 -> sString;

foreach (
$aCheck as $clef => $val) {
    
$soundex2 -> build ($val);
    
$level levenshtein (strtolower ($sString), strtolower ($val));
    if (
$soundex2 -> sString === $sSoundex) {
        
$aWords[] = $val;
        
$aDistance[] = $level;
    }
}
array_multisort ($aDistance$aWords);
$aChecked array_combine ($aWords$aDistance);
echo 
'Soundex2 checked for ['$sString'] these entries : <br />';
echo 
'<pre>'print_r ($aChecked), '</pre>';


$aChecked $aWords $aDistance = array ();


$sString 'gros';
$soundex2 -> build ($sString);
$sSoundex $soundex2 -> sString;

foreach (
$aCheck as $clef => $val) {
    
$soundex2 -> build ($val);
    
$level levenshtein (strtolower ($sString), strtolower ($val));
    if (
$soundex2 -> sString === $sSoundex) {
        
$aWords[] = $val;
        
$aDistance[] = $level;
    }
}
array_multisort ($aDistance$aWords);
$aChecked array_combine ($aWords$aDistance);
echo 
'Soundex2 checked for ['$sString'] these entries : <br />';
echo 
'<pre>'print_r ($aChecked), '</pre>';

?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products