3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = <<<'JSON' { "abc": 157, "efg": 1, "hij": "1", "klm": "0.00", "created_at": { "date": "2020-04-08 12:53:34.682759", "timezone_type": 3, "timezone": "UTC" }, "updated_at": { "date": "2020-04-08 12:53:34.682759", "timezone_type": 3, "timezone": "UTC" } } JSON; $arr = json_decode($json, true); function delete_key(&$arr, $key) { foreach($arr as $k => &$v) { if ( $k === $key ) { unset($arr[$k]); continue; } if ( is_array($v) ) { delete_key($v, $key); } } } delete_key($arr, 'date'); print_r(json_encode($arr, JSON_PRETTY_PRINT));
Output for 7.2.0 - 7.2.29, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.27, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
{ "abc": 157, "efg": 1, "hij": "1", "klm": "0.00", "created_at": { "timezone_type": 3, "timezone": "UTC" }, "updated_at": { "timezone_type": 3, "timezone": "UTC" } }

preferences:
128.92 ms | 407 KiB | 5 Q