<?php
$json = '{
"credit_card": {
"cvc": "123",
"expiry": {
"month": "12",
"year": "2019"
},
"name": "Julian",
"number": "5123450000000008",
"token": null
},
"amount": "10",
"currency": "AUD",
"gateway": {
"line_of_business": "eWallet",
"service": "default",
"username": null
},
"external_id": "my external id",
"reference": "julian test",
"remitter_name": null,
"request_id": "1529561070",
"statement_description": null,
"security_id": null
}';
$array = json_decode($json, true);
function test_print($item, $key, &$array)
{
if ($item === null) unset($array[$key]);
}
array_walk_recursive($array, 'test_print');
var_dump($array);
preferences:
52.31 ms | 402 KiB | 5 Q