note 37290 deleted from function.similar-text by didou
| From: | didou@php.net | Date: | Sun, 09 Nov 2003 15:18:47 +0000 |
| Subject: | note 37290 deleted from function.similar-text by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-60173@lists.php.net to get a copy of this message | ||
Note Submitter: Christo Fogelberg
----
A minor correction or two to georgesk's code of 9 March 2002:
He initialises the array with:
$LCS_Length_Table = array(array(128),array(128));
and then resets the relevant columns to 0, except that this doesn't create a 128-by-128 array,
which I think is his intention. The code to do that is - and if anyone knows a prettier version,
please post! - something like:
$LCS_Length_Table = array_pad(array(), 128, array_pad(array(), 128, 0));
Alternatively, if you want to allocate only as much space as needed, but no more than 128 chars per
string, then use:
$LCS_Length_Table = array_pad(array(), min($m, 128)+1, array_pad(array(), min($n, 128)+1, 0));
(You need the +1 because we actually use indexes up to strlen($s1) and strlen($s2), but PHP arrays
are 0-based of course).
Other than that though, some very nice code! :-)
Christo