I have a string value held in a var, I want to compare it against a array and print the array number that is the nearest match whilst being case sensitive.
so the question is how do I find the nearest match within my array to my var $bio
in this case it would be 4
I have seen pregmatch but am unsure on how to use it in this case.
Code I have
<?php
$bio= "Tom, male, spain";
$list= array(
1 => array("Tom", "male", "UK"),
8 => array("bob", "Male", "spain"),
4 => array("Tom", "male", "spain"),
9 => array("sam", "femail", "United States")
);
function best_match($bio, $list)
{
}
I was thinking something like thinking
$matches = preg_grep ($bio, $list);
print_r ($matches);