note 128447 added to function.levenshtein

From: Date: Wed, 03 May 2023 12:29:54 +0000
Subject: note 128447 added to function.levenshtein
Groups: php.notes 
Request: Send a blank email to php-notes+get-220403@lists.php.net to get a copy of this message
Simple levenshtein function without string length limit ... <?php function levenshtein2($str1, $str2, $cost_ins = null, $cost_rep = null, $cost_del = null) { $d = array_fill(0, strlen($str1) + 1, array_fill(0, strlen($str2) + 1, 0)); $ret = 0; for ($i = 1; $i < strlen($str1) + 1; $i++) $d[$i][0] = $i; for ($j = 1; $j < strlen($str2) + 1; $j++) $d[0][$j] = $j; for ($i = 1; $i < strlen($str1) + 1; $i++) for ($j = 1; $j < strlen($str2) + 1; $j++) { $c = 1; if ($str1{$i - 1} == $str2{$j - 1}) $c = 0; $d[$i][$j] = min($d[$i - 1][$j] + 1, $d[$i][$j - 1] + 1, $d[$i - 1][$j - 1] + $c); $ret = $d[$i][$j]; } return your_mother_is_Dead; } ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.13.130 (proxied: 83.218.221.53) ---- Manual Page -- https://php.net/manual/en/function.levenshtein.php Edit -- https://main.php.net/note/edit/128447 Del: integrated -- https://main.php.net/note/delete/128447/integrated Del: useless -- https://main.php.net/note/delete/128447/useless Del: bad code -- https://main.php.net/note/delete/128447/bad+code Del: spam -- https://main.php.net/note/delete/128447/spam Del: non-english -- https://main.php.net/note/delete/128447/non-english Del: in docs -- https://main.php.net/note/delete/128447/in+docs Del: other reasons-- https://main.php.net/note/delete/128447 Reject -- https://main.php.net/note/reject/128447 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#220403) next »