如果找到此键,则在foreach循环上取消设置关联数组

I have an array of data, all I wanted is to check if this key is found, cause if it is I will unset a certain array

This would be my example array:

Array
(
  [2019-01-01] => Array(
     [1] => Array(
        ['OLD'] => Array(
          [0] => Array(
            ['id']=>1,
            ['name']=>full name
          )
        )
        ['NEW'] => Array(
          [0] => Array(
            ['id']=>2,
            ['name']=>full name
          )
        )
     )
  )
  [2019-01-02] => Array(
     [1] => Array(
        ['OLD'] => Array(
          [0] => Array(
            ['id']=>5,
            ['name']=>full name
          )
        )
     )
  )
)

I have this code:

foreach ($my_array as $key=>$val) {
  foreach ($val as $key=>$val) {
    foreach ($val as $key=>$val) {
      // I wanted to check in this part if this array has `$key` OLD and `$key` NEW, if it has new then unset OLD
    }
  }
}

My expected result would be the OLD to be removed if there is NEW, but If there is no NEW then retain OLD array. What is the proper array function to use here?

Simply array_walk() might help you. Example:

array_walk($arr, function (&$item) {
    if(isset($item[1]['OLD'], $item[1]['NEW'])) unset($item[1]['OLD']);
});