There is this array:
$array1 = array(51=>1.1, 45=>68, 57=>43, 62=>35, 74=>24);
And I want to verify if the value that is taken from the variable starts with any of the keys from the array. (the variable is passing correctly, I checked that)
foreach (array_keys($array1) as $key1) {
if(preg_match("/^[$rvalue]/", $key1))
{
$positive1=true;
$fvalue1=$array1[$key1];
}
else{
$positive1=false;
}
}
The problem is that it runs all the array and always gives me the value of the last key, instead of one matching the variable. I'm new with regex, so might be that, don't know. Any help is appreciated.