3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ "date_2018_08" => 81, "date_2018_09" => 70, "date_2018_10" => 70, "date_2018_11" => 95, "date_2018_12" => 75, "date_2019_01" => 91, "date_2019_02" => 78, "date_2019_03" => 95, "date_2019_04" => 68, ]; $year = 2019; $month = str_pad(4,2,"0",STR_PAD_LEFT); $temp = array_filter($array, function ($key) use ($year, $month) { return (strpos($key, $year . "_" . $month) === false); }, ARRAY_FILTER_USE_KEY); print_r($temp);die;
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.32, 8.0.0 - 8.0.24, 8.1.0 - 8.1.11
Array ( [date_2018_08] => 81 [date_2018_09] => 70 [date_2018_10] => 70 [date_2018_11] => 95 [date_2018_12] => 75 [date_2019_01] => 91 [date_2019_02] => 78 [date_2019_03] => 95 )

preferences:
61.99 ms | 410 KiB | 5 Q