3v4l.org

run code in 300+ PHP versions simultaneously
<?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; $decoded = json_decode($json, true); 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']); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 16
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 15
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/chlto
function name:  (null)
number of ops:  18
compiled vars:  !0 = $json, !1 = $decoded, !2 = $val, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5B%0A%7B%0A%22id%22%3A23%2C%0A%22uid%22%3A%220090000219%22%2C%0A%22cid%22%3A%220090000013%22%2C%0A%22extension%22%3A%22201%22%2C%0A%22secret%22%3A%22Myojyo42_f%22%2C%0A%22leader%22%3Atrue%2C%0A%22simultaneous%22%3Afalse%2C%0A%22confbridge_id%22%3A17%2C%0A%22created_at%22%3A%222015-09-02+12%3A49%3A12%22%2C%0A%22updated_at%22%3A%222015-09-02+12%3A49%3A12%22%0A%7D%2C%0A%7B%0A%22id%22%3A24%2C%0A%22uid%22%3A%220090000221%22%2C%0A%22cid%22%3A%220090000013%22%2C%0A%22extension%22%3A%22203%22%2C%0A%22secret%22%3A%22Myojyo42_f%22%2C%0A%22leader%22%3Afalse%2C%0A%22simultaneous%22%3Afalse%2C%0A%22confbridge_id%22%3A17%2C%0A%22created_at%22%3A%222015-09-02+12%3A49%3A12%22%2C%0A%22updated_at%22%3A%222015-09-02+12%3A49%3A12%22%0A%7D%2C%0A%7B%0A%22id%22%3A25%2C%0A%22uid%22%3A%220090000223%22%2C%0A%22cid%22%3A%220090000013%22%2C%0A%22extension%22%3A%22205%22%2C%0A%22secret%22%3A%22Myojyo42_f%22%2C%0A%22leader%22%3Atrue%2C%0A%22simultaneous%22%3Afalse%2C%0A%22confbridge_id%22%3A17%2C%0A%22created_at%22%3A%222015-09-10+10%3A16%3A24%22%2C%0A%22updated_at%22%3A%222015-09-10+10%3A16%3A24%22%0A%7D%0A%5D'
   44     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
   45     6      > FE_RESET_R                                       $7      !1, ->16
          7    > > FE_FETCH_R                                       ~8      $7, !2, ->16
          8    >   ASSIGN                                                   !3, ~8
   47     9        FETCH_DIM_R                                      ~10     !2, 'leader'
         10        IS_EQUAL                                                 ~10, 1
         11      > JMPZ                                                     ~11, ->15
   49    12    >   FETCH_DIM_R                                      ~12     !2, 'leader'
         13        COUNT                                            ~13     ~12
         14        ECHO                                                     ~13
   45    15    > > JMP                                                      ->7
         16    >   FE_FREE                                                  $7
   52    17      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
186.03 ms | 1396 KiB | 15 Q