@ 2015-09-11T07:02:04Z <?php
$json=<<<EOF
[
{
"id":23,
"uid":"0090000219",
"cid":"0090000013",
"extension":"201",
"secret":"Myojyo42_f",
"leader":true,
"simultaneous":false,
"confbridge_id":17,
"created_at":"2015-09-02 12:49:12",
"updated_at":"2015-09-02 12:49:12"
},
{
"id":24,
"uid":"0090000221",
"cid":"0090000013",
"extension":"203",
"secret":"Myojyo42_f",
"leader":false,
"simultaneous":false,
"confbridge_id":17,
"created_at":"2015-09-02 12:49:12",
"updated_at":"2015-09-02 12:49:12"
},
{
"id":25,
"uid":"0090000223",
"cid":"0090000013",
"extension":"205",
"secret":"Myojyo42_f",
"leader":true,
"simultaneous":false,
"confbridge_id":17,
"created_at":"2015-09-10 10:16:24",
"updated_at":"2015-09-10 10:16:24"
}
]
EOF;
foreach($decoded as $key => $val)
{
if($val['leader'] == 1)
{
echo count($val['leader']);
}
//if you want also to count the false then add else in the statement echo count($val['leader']);
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 Warning: Undefined variable $decoded in /in/kSM6B on line 44
Warning: foreach() argument must be of type array|object, null given in /in/kSM6B on line 44
Output for 5.4.2 - 5.4.45 , 5.5.24 - 5.5.35 , 5.6.7 - 5.6.28 , 7.0.0 - 7.0.20 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.31 , 7.4.0 - 7.4.33 Notice: Undefined variable: decoded in /in/kSM6B on line 44
Warning: Invalid argument supplied for foreach() in /in/kSM6B on line 44
Output for 7.3.32 - 7.3.33 Warning: Invalid argument supplied for foreach() in /in/kSM6B on line 44
preferences:dark mode live preview
201.65 ms | 401 KiB | 255 Q