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 Foreach($arr['Body']['stkCallback']['CallbackMetadata']['Item'] as $subarr){ Foreach($subarr as $item){ Echo $item ."\n"; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 24
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 24
Branch analysis from position: 17
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 22
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 22
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/AJn9N
function name:  (null)
number of ops:  26
compiled vars:  !0 = $str, !1 = $arr, !2 = $subarr, !3 = $item
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'
    7     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
    9     6        FETCH_DIM_R                                      ~7      !1, 'Body'
          7        FETCH_DIM_R                                      ~8      ~7, 'stkCallback'
          8        FETCH_DIM_R                                      ~9      ~8, 'MerchantRequestID'
          9        CONCAT                                           ~10     ~9, '%0A'
         10        ECHO                                                     ~10
   11    11        FETCH_DIM_R                                      ~11     !1, 'Body'
         12        FETCH_DIM_R                                      ~12     ~11, 'stkCallback'
         13        FETCH_DIM_R                                      ~13     ~12, 'CallbackMetadata'
         14        FETCH_DIM_R                                      ~14     ~13, 'Item'
         15      > FE_RESET_R                                       $15     ~14, ->24
         16    > > FE_FETCH_R                                               $15, !2, ->24
   12    17    > > FE_RESET_R                                       $16     !2, ->22
         18    > > FE_FETCH_R                                               $16, !3, ->22
   13    19    >   CONCAT                                           ~17     !3, '%0A'
         20        ECHO                                                     ~17
   12    21      > JMP                                                      ->18
         22    >   FE_FREE                                                  $16
   11    23      > JMP                                                      ->16
         24    >   FE_FREE                                                  $15
   15    25      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.3 ms | 999 KiB | 14 Q