I have an array
$op1 = array('45'=>123, '657'=>65, '6578'=>234, '65782'=>0, '3'=>25, '756'=>156, '3445'=>178, '20924'=>92);
And then a variable taken from a form that I want to see if any of the array keys starts with it.
Variable: $nr=$_POST['number'];
Code:
foreach (array_keys($op1) as $key) {
if(preg_match('/$nr/', $key))
{
echo "FOUND";
}
else{
echo "NOT FOUND";
}
But it never finds anything in the array. I know that I am probably doing something wrong, but don't know what.