3v4l.org

run code in 300+ PHP versions simultaneously
<?php $records = [ [ "Id" => 151601, "First_name" => "John", "Positions" => [ "North" => [ "Current_Level" => 4, "Last_Date" => "11/7/2001", "Time" => "4:15 AM" ], "East" => [ "Current_Level" => 4, "Last_Date" => "7/10/2003", "Time" => "7:30 PM" ], "South" => [ "Current_Level" => 2, "Last_Date" => "8/10/2007", "Time" => "NA" ], "West" => [ "Current_Par_Level" => "NA", "Last_Date" => "NA", "Time" => "NA" ], ] ] ]; foreach ($records as $keyRecord => $record) { foreach ($record as $key => $value) { if (is_array($value)) { foreach ($value as $keyPosition => $position) { if ($position["Time"] == "NA") { unset($records[$keyRecord][$key][$keyPosition]); } } } } } print_r($records);
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Array ( [0] => Array ( [Id] => 151601 [First_name] => John [Positions] => Array ( [North] => Array ( [Current_Level] => 4 [Last_Date] => 11/7/2001 [Time] => 4:15 AM ) [East] => Array ( [Current_Level] => 4 [Last_Date] => 7/10/2003 [Time] => 7:30 PM ) ) ) )

preferences:
93.61 ms | 1660 KiB | 4 Q