note 105488 deleted from function.similar-text by danbrown

From: Date: Mon, 22 Aug 2011 14:01:18 +0000
Subject: note 105488 deleted from function.similar-text by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-182641@lists.php.net to get a copy of this message
Note Submitter: lukasamd at gmail dot com ---- According to romain dot boyer at gmail dot com 08-Aug-2007 12:59: " Like levenchtein(), You can do : (strlen($string2) - similar_text($string,$string2)) to see how much characters have been changed. " Yes, but we have to remember about strings length - if first string is longer, we must substract from first length, if not, from second: <?php $string_first = 'Lorem ipsum'; $string_new = 'Lorem dolor'; $length_string_first = strlen($string_first); $length_string_new = strlen($string_new); if ($length_string_first > $length_string_new) { $changed_chars = ($length_string_first - similar_text($string_first, $string_new)); } else { $changed_chars = ($length_string_new - similar_text($string_first, $string_new)); } ?>

« previous php.notes (#182641) next »