, // returning a filtered multidimensional array , $id = 16058777725fb7c00c0b865; , , $data = json_decode(file_get_contents($mileage),true); , , function filterArrayByKeyValue($array, $key, $keyValue) { , return array_filter($array, function($value) use ($key, $keyValue) { , return $value$key == $keyValue; , }); , } , , // call to function , $data = filterArrayByKeyValue($data, vehicle_id, $id); , , $mileage: , , Array , ( , 0 => Array , ( , mileage_id => 16067419145fc4ef9a6aad2 , vehicle_id => 16058777725fb7c00c0b865 , mileage_date => 2020-11-25 , mileage_mileage => 3228 , mileage_gallons => 2.3 , mileage_item => , mileage_oil_change => , ) , , 1 => Array , ( , mileage_id => 16067398705fc4e79e8dfde , vehicle_id => 16058777725fb7c00c0b865 , mileage_date => 2020-11-07 , mileage_mileage => 3094 , mileage_gallons => 2.19 , mileage_item => , mileage_oil_change => , ) , , 2 => Array , ( , mileage_id => 16067397105fc4e6fe2f955 , vehicle_id => 16058777725fb7c00c0b865 , mileage_date => 2020-10-21 , mileage_mileage => 2978 , mileage_gallons => , mileage_item => , mileage_oil_change => , ) , ) ,