3v4l.org

run code in 300+ PHP versions simultaneously
<?php $response = '{ "nhif":[ { "id_number":"AA112233", "amount":"5", "date":"2018-09-14T20:18:50" }, { "id_number":"AA112233", "amount":"5", "date":"2018-09-14T19:59:14" }, { "id_number":"AA112233", "amount":"5", "date":"2018-09-14T09:07:34" }, { "id_number":"AA112233", "amount":"5", "date":"2018-09-14T09:04:27" }, { "id_number":"12345678", "amount":"5", "date":"2018-09-14T09:04:21" } ] }'; $json_response = json_decode($response, true); $r = []; foreach ($json_response['nhif'] as $nhif) { isset($r[$nhif['id_number']]) ? $r[$nhif['id_number']] += $nhif['amount'] : $r[$nhif['id_number']] = $nhif['amount']; } print_r($r);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 26
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 26
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 19
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/9XKFO
function name:  (null)
number of ops:  31
compiled vars:  !0 = $response, !1 = $json_response, !2 = $r, !3 = $nhif
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7B%0A+++++++++++++++%22nhif%22%3A%5B%0A++++++++++++++++++%7B%0A+++++++++++++++++++++%22id_number%22%3A%22AA112233%22%2C%0A+++++++++++++++++++++%22amount%22%3A%225%22%2C%0A+++++++++++++++++++++%22date%22%3A%222018-09-14T20%3A18%3A50%22%0A++++++++++++++++++%7D%2C%0A++++++++++++++++++%7B%0A+++++++++++++++++++++%22id_number%22%3A%22AA112233%22%2C%0A+++++++++++++++++++++%22amount%22%3A%225%22%2C%0A+++++++++++++++++++++%22date%22%3A%222018-09-14T19%3A59%3A14%22%0A++++++++++++++++++%7D%2C%0A++++++++++++++++++%7B%0A+++++++++++++++++++++%22id_number%22%3A%22AA112233%22%2C%0A+++++++++++++++++++++%22amount%22%3A%225%22%2C%0A+++++++++++++++++++++%22date%22%3A%222018-09-14T09%3A07%3A34%22%0A++++++++++++++++++%7D%2C%0A++++++++++++++++++%7B%0A+++++++++++++++++++++%22id_number%22%3A%22AA112233%22%2C%0A+++++++++++++++++++++%22amount%22%3A%225%22%2C%0A+++++++++++++++++++++%22date%22%3A%222018-09-14T09%3A04%3A27%22%0A++++++++++++++++++%7D%2C%0A++++++++++++++++++%7B%0A+++++++++++++++++++++%22id_number%22%3A%2212345678%22%2C%0A+++++++++++++++++++++%22amount%22%3A%225%22%2C%0A+++++++++++++++++++++%22date%22%3A%222018-09-14T09%3A04%3A21%22%0A++++++++++++++++++%7D%0A+++++++++++++++%5D%0A++++++++++++%7D'
   32     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
   34     6        ASSIGN                                                   !2, <array>
   35     7        FETCH_DIM_R                                      ~8      !1, 'nhif'
          8      > FE_RESET_R                                       $9      ~8, ->26
          9    > > FE_FETCH_R                                               $9, !3, ->26
   36    10    >   FETCH_DIM_R                                      ~10     !3, 'id_number'
         11        ISSET_ISEMPTY_DIM_OBJ                         0          !2, ~10
         12      > JMPZ                                                     ~11, ->19
         13    >   FETCH_DIM_R                                      ~12     !3, 'id_number'
         14        FETCH_DIM_R                                      ~14     !3, 'amount'
         15        ASSIGN_DIM_OP                +=               1  ~13     !2, ~12
         16        OP_DATA                                                  ~14
         17        QM_ASSIGN                                        ~15     ~13
         18      > JMP                                                      ->24
         19    >   FETCH_DIM_R                                      ~16     !3, 'id_number'
         20        FETCH_DIM_R                                      ~18     !3, 'amount'
         21        ASSIGN_DIM                                       ~17     !2, ~16
         22        OP_DATA                                                  ~18
         23        QM_ASSIGN                                        ~15     ~17
         24    >   FREE                                                     ~15
   35    25      > JMP                                                      ->9
         26    >   FE_FREE                                                  $9
   39    27        INIT_FCALL                                               'print_r'
         28        SEND_VAR                                                 !2
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
217.53 ms | 1006 KiB | 15 Q