I have a JSON as shown below in which I want to calculate through php how many values are present inside posts_id_en. At present, it is 7 as shown below:
{
"posts_id_en": "149968, 149939, 149883, 149877, 149876, 149847, 154303",
"posts_id_fr": "149974,149953,149926, 149920, 149901",
"episode_status": "3"
}
In php code on doing echo $data->{"posts_id_en"};, it displays the values as shown below:
149968, 149939, 149883, 149877, 149876, 149847, 154303
Problem Statement:
I am wondering what php code I need to use so that we can calculate number of values entered inside posts_id_en. At this moment, it is entered 7 as shown above.
$cnt = preg_match_all('/(?:\G(?!^)|"posts_id_en":\s*")[^",]+,?/', $str);but I'd prefer thejson_decodetoo :p