3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = '{"Body": {"stkCallback": {"MerchantRequestID":"26452-605723-2","CheckoutRequestID":"ws_CO_23042018105859659","ResultCode":0,"ResultDesc":"The service request is processed successfully.","CallbackMetadata": {"Item":[{"Name":"Amount","Value":1.00},{"Name":"MpesaReceiptNumber","Value":"MDN6ZJE4XG"},{"Name":"Balance"},{"Name":"TransactionDate","Value":20180423105912},{"Name":"PhoneNumber","Value":254722200121}]}}}}'; $arr = json_decode($str,true); echo $arr['Body']['stkCallback']['MerchantRequestID'] . "\n"; // Working //echo $arr['Body']['stkCallback']['CallbackMetadata'] . "\n"; echo $arr['Body']['stkCallback']['CallbackMetadata']['Item'][1]['Value'] . "\n"; echo $arr['Body']['stkCallback']['CallbackMetadata']['Item'][3]['Value'] . "\n"; echo $arr['Body']['stkCallback']['CallbackMetadata']['Item'][4]['Value'] . "\n"; echo $arr['Body']['stkCallback']['CallbackMetadata']['Item'][0]['Value'] ."\n"; /*Foreach($arr['Body']['stkCallback']['CallbackMetadata']['Item'] as $subarr){ Foreach($subarr as $item){ Echo $item ."\n"; } } */
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rYfdr
function name:  (null)
number of ops:  44
compiled vars:  !0 = $str, !1 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7B%22Body%22%3A%0A+%7B%22stkCallback%22%3A%0A++++%7B%22MerchantRequestID%22%3A%2226452-605723-2%22%2C%22CheckoutRequestID%22%3A%22ws_CO_23042018105859659%22%2C%22ResultCode%22%3A0%2C%22ResultDesc%22%3A%22The+service+request+is+processed+successfully.%22%2C%22CallbackMetadata%22%3A%0A%7B%22Item%22%3A%5B%7B%22Name%22%3A%22Amount%22%2C%22Value%22%3A1.00%7D%2C%7B%22Name%22%3A%22MpesaReceiptNumber%22%2C%22Value%22%3A%22MDN6ZJE4XG%22%7D%2C%7B%22Name%22%3A%22Balance%22%7D%2C%7B%22Name%22%3A%22TransactionDate%22%2C%22Value%22%3A20180423105912%7D%2C%7B%22Name%22%3A%22PhoneNumber%22%2C%22Value%22%3A254722200121%7D%5D%7D%7D%7D%7D'
    8     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !1, $3
   10     6        FETCH_DIM_R                                      ~5      !1, 'Body'
          7        FETCH_DIM_R                                      ~6      ~5, 'stkCallback'
          8        FETCH_DIM_R                                      ~7      ~6, 'MerchantRequestID'
          9        CONCAT                                           ~8      ~7, '%0A'
         10        ECHO                                                     ~8
   12    11        FETCH_DIM_R                                      ~9      !1, 'Body'
         12        FETCH_DIM_R                                      ~10     ~9, 'stkCallback'
         13        FETCH_DIM_R                                      ~11     ~10, 'CallbackMetadata'
         14        FETCH_DIM_R                                      ~12     ~11, 'Item'
         15        FETCH_DIM_R                                      ~13     ~12, 1
         16        FETCH_DIM_R                                      ~14     ~13, 'Value'
         17        CONCAT                                           ~15     ~14, '%0A'
         18        ECHO                                                     ~15
   13    19        FETCH_DIM_R                                      ~16     !1, 'Body'
         20        FETCH_DIM_R                                      ~17     ~16, 'stkCallback'
         21        FETCH_DIM_R                                      ~18     ~17, 'CallbackMetadata'
         22        FETCH_DIM_R                                      ~19     ~18, 'Item'
         23        FETCH_DIM_R                                      ~20     ~19, 3
         24        FETCH_DIM_R                                      ~21     ~20, 'Value'
         25        CONCAT                                           ~22     ~21, '%0A'
         26        ECHO                                                     ~22
   14    27        FETCH_DIM_R                                      ~23     !1, 'Body'
         28        FETCH_DIM_R                                      ~24     ~23, 'stkCallback'
         29        FETCH_DIM_R                                      ~25     ~24, 'CallbackMetadata'
         30        FETCH_DIM_R                                      ~26     ~25, 'Item'
         31        FETCH_DIM_R                                      ~27     ~26, 4
         32        FETCH_DIM_R                                      ~28     ~27, 'Value'
         33        CONCAT                                           ~29     ~28, '%0A'
         34        ECHO                                                     ~29
   15    35        FETCH_DIM_R                                      ~30     !1, 'Body'
         36        FETCH_DIM_R                                      ~31     ~30, 'stkCallback'
         37        FETCH_DIM_R                                      ~32     ~31, 'CallbackMetadata'
         38        FETCH_DIM_R                                      ~33     ~32, 'Item'
         39        FETCH_DIM_R                                      ~34     ~33, 0
         40        FETCH_DIM_R                                      ~35     ~34, 'Value'
         41        CONCAT                                           ~36     ~35, '%0A'
         42        ECHO                                                     ~36
   24    43      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
121.71 ms | 1450 KiB | 14 Q