I have a json result below.
$abc = '{
"id":"375",
"name":"Nilesh Y",
"email":"nilesh.yadav@test.co.in",
"mobile":"9076330330",
"tracking_number":null,
"home_tagged_address_id":null,
"office_tagged_address_id":null,
"time":1427254525,
"logged_in":true,
"method":true,
"error":null,
"home_address":null,
"office_address":null
}';
$a = json_decode($abc,true,JSON_BIGINT_AS_STRING);
print_r($a);
after json_decode decode the result is .
Array ( [id] => 375 [name] => Nilesh Y [email] => nilesh.yadav@intelliswift.co.in [mobile] => 9076330330 [tracking_number] => [home_tagged_address_id] => [office_tagged_address_id] => [time] => 1427254525 [logged_in] => 1 [method] => 1 [error] => [home_address] => [office_address] => )
If u see the result it removed the error : null and home_address : null
means [home_address] => ""
is blank
I want to print that null value in array kindly let me know how to do that
Use var_dump instead of print_r. Install the xdebug extension which will make var_dump’s output even nicer.
Do you see? ( http://3v4l.org/Y58fC )
var_dump()
will output the following:You see,
json_decode()
is working as expected you simply couldn’t see it sinceprint_r
will print nothing for a NULL.Check result as:
you have received your intended result itself.
When you do print_r, null value are not displayed.
The proof itself is that key exists while value doesn’t.
you can confirm using var_dump