I've PHP array something like this
$array = array("foo", "bar", "hallo", "world", "fooo", "bar1", "hall_o", "wor1ld", "foo", "bard", "hzallo", "w44orld");
I want to compare each element of an array with remaining elements.
Ex: I want to compre "foo" with "bar", "hallo", "world", "fooo", "bar1", "hall_o", "wor1ld", "foo", "bard", "hzallo" and "w44orld"
.
Then, I want to compre "bar" with "foo", "hallo", "world", "fooo", "bar1", "hall_o", "wor1ld", "foo", "bard", "hzallo", "w44orld"
and so on till last element.
Let's consider element, which we are comparing as $var_1
and variable for remaining elements as $var_2;
If similar_text($var_1, $var_2, $percent);
returns $percent value > 90%
then I want to print
$var_1
and all corresponding similar text values of $var_2
for which matching percentage > 90
Currently I'm planning to use two loops to achieve this, external loop for $var_1
and internal loop for $var_2
.
Each element of the array
can have value upto 5000 characters and there can be 1000 elements in a array, so my current logic is very expensive.
Any direction to handle it in better way?