note 117651 added to function.levenshtein

From: Date: Wed, 15 Jul 2015 08:19:23 +0000
Subject: note 117651 added to function.levenshtein
Groups: php.notes 
Request: Send a blank email to php-notes+get-203110@lists.php.net to get a copy of this message
Some small changes allow you to calculate multiple words. <?php $input = array(); $dictionary = array(); foreach ($input as $output) { $shortest = -1; foreach ($dictionary as $word) { $lev = levenshtein($output, $word); if ($lev == 0) { $closest = $word; $shortest = 0; } if ($lev <= $shortest || $shortest < 0) { $closest = $word; $shortest = $lev; } } echo "Input word: $output\n"; if ($shortest == 0) { echo "Exact match found: $closest\n"; } else { echo "Did you mean: $closest?\n"; } } ?> ---- Server IP: 64.71.164.2 Probable Submitter: 124.168.9.177 ---- Manual Page -- http://php.net/manual/en/function.levenshtein.php Edit -- https://master.php.net/note/edit/117651 Del: integrated -- https://master.php.net/note/delete/117651/integrated Del: useless -- https://master.php.net/note/delete/117651/useless Del: bad code -- https://master.php.net/note/delete/117651/bad+code Del: spam -- https://master.php.net/note/delete/117651/spam Del: non-english -- https://master.php.net/note/delete/117651/non-english Del: in docs -- https://master.php.net/note/delete/117651/in+docs Del: other reasons-- https://master.php.net/note/delete/117651 Reject -- https://master.php.net/note/reject/117651 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#203110) next »