In the below code, the IF case is TRUE also for each time the $value is 0. To fix that, I had to change "==" to "===".
Can I please get an explanation why ? How come comparing to the specific string getting TRUE on 0 as well.
<?php
date_default_timezone_set('EST'); //time set to GMT base
$json_file = '[
{
"ACCOUNT_ID": -1,
"ACC_NAME": "acc name not found",
"TT4": 1955801736,
"TT7": 0,
"TT8": 0
},
{
"ACCOUNT_ID": 841,
"ACC_NAME": "Appnexus",
"WEEK_REQ": 66306441448,
"TT16": 16570453480,
"TT_NULL": 0,
"ORDER_ID": 1
},
{
"ACCOUNT_ID": 730,
"ACC_NAME": "MediaMath",
"WEEK_REQ": 17816846018,
"WEEK_CLASS_RATE": 87.65,
"TT16": 0,
"TT_NULL": 0,
"ORDER_ID": 1
}
]';
$j = json_decode($json_file);
foreach ($j as $row)
{
foreach($row as $key=>$value)
{
if ($value == 'acc name not found')
{
echo $key . " - " . $value;
echo "<br>";
}
}
}
?>