note 109507 modified in function.similar-text by danbrown
| From: | danbrown@php.net | Date: | Mon, 30 Jul 2012 15:56:13 +0000 |
| Subject: | note 109507 modified in function.similar-text by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189501@lists.php.net to get a copy of this message | ||
Hey there, Be aware when using this function, that the order of
passing the strings is very important if you want to calculate the percentage of similarity, in
fact, altering the variables will give a very different result, example
: <?php $var_1 = 'PHP IS
GREAT'; $var_2 = 'WITH
MYSQL'; similar_text($var_1, $var_2,
$percent); echo $percent; //
27.272727272727 similar_text($var_2, $var_1,
$percent); echo $percent; //
18.181818181818 ?>
--was--
Hey there,
Be aware when using this function, that the order of passing the strings is very important if you
want to calculate the percentage of similarity, in fact, altering the variables will give a very
different result, example :
$var_1 = 'PHP IS GREAT';
$var_2 = 'WITH MYSQL';
similar_text($var_1, $var_2, $percent);
echo $percent;
// 27.272727272727
similar_text($var_2, $var_1, $percent);
echo $percent;
// 18.181818181818
http://php.net/manual/en/function.similar-text.php