I am trying to create a function in PHP that matches a string, allows you to say “1234567” with the best matching match prefix, although there are a few matches, select the best one.
For example, if we have all of this:
(1, 12, 123, 1234, 456, 56, 7, 3456, 234567)
Input = "1234567"
The output must be = "1234"
Because the prefix that matches the best (despite 1, 12 and 123 matching, is also no better than 1234, and despite the fact that 234567 is the best match in general, it is not a prefix).
I do not know if this function is implemented by default in PHP
source
share