[key.usage] => 0
[key.time] => 30000
[my.key0.time] => 331
[my.key1.time] => 331
[my.key2.time] => 331
$count = array_reduce(array_keys($arr), function($acc, $n) {
return $acc + (strpos($n, 'my.key') === 0);
}, 0);
$pattern = '/my.key.*/';
$count = null;
foreach ($arr as $key => $value) {
if (!preg_match($pattern, $key, $match)) {
continue;
}
$count += 1;
}
echo $count;