PHP Classes
elePHPant
Icontem

File: index.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Johan Barbier  >  Soundex 2  >  index.php  >  Download  
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
Author: By
Last change: Changed path
Date: 8 years ago
Size: 1,982 bytes
 

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>';

?>