Location: PHPKode > scripts > Phonex > phonex/index.php
<?php
require_once 'class/php5/phonex.cls.php';
$oPhonex = new phonex;

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

$sString = 'rousseau';

$oPhonex -> build ($sString);
$sPhonex = $oPhonex -> sString;

foreach ($aCheck as $clef => $val) {
	$oPhonex -> build ($val);
	$level = levenshtein (strtolower ($sString), strtolower ($val) );
	if ($oPhonex -> sString === $sPhonex) {
		$aWords[] = $val;
		$aDistance[] = $level;
	}
}
array_multisort ($aDistance, $aWords);
$aChecked = array_combine ($aWords, $aDistance);


echo 'Phonex checked for [', $sString, '] these entries : <br />';
echo '<pre>', print_r ($aChecked), '</pre>';


$aChecked = $aWords = $aDistance = array ();


$sString = 'gros';
$oPhonex -> build ($sString);
$sPhonex = $oPhonex -> sString;

foreach ($aCheck as $clef => $val) {
	$oPhonex -> build ($val);
	$level = levenshtein (strtolower ($sString), strtolower ($val) );
	if ($oPhonex -> sString === $sPhonex) {
		$aWords[] = $val;
		$aDistance[] = $level;
	}
}
array_multisort ($aDistance, $aWords);
$aChecked = array_combine ($aWords, $aDistance);

echo 'Phonex checked for [', $sString, '] these entries : <br />';
echo '<pre>', print_r ($aChecked), '</pre>';

$aChecked = $aWords = $aDistance = array ();


$sString = 'moulin';
$oPhonex -> build ($sString);
$sPhonex = $oPhonex -> sString;

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

?>
Return current item: Phonex