I have a PHP/JSON as show below.
JSON:
{"posts_id_en":"101, 102, 103","posts_id_fr":"", "reports_id_en":"101, 102", "reports_id_fr":"101"}
PHP code:
echo count(explode(",", $data->posts_id_en)); // Line A (3)
echo count(explode(",", $data->posts_id_fr)); // Line B (1)
echo count(explode(",", $data->reports_id_en)); // Line C (2)
echo count(explode(",", $data->reports_id_fr)); // Line D (1)
Line A php code, Line C php code and Line D php code print 3
, 2
, and 1
.
Problem Statement:
I am wondering what changes I need to make in the php code above at Line B so that it prints 0 as there are no elements inside posts_id_fr