3v4l.org

run code in 500+ PHP versions simultaneously
<?php // take the badly formatted JSON $result = '{ "price": [ { "price": "2000", "origin_name": "JPN", }, { "price": "5000", "origin_name": "USA", } ] }'; // and remove the superfluous commas: $pat = "/(o.+),/"; $replace = "$1"; $nu_result = preg_replace($pat,$replace,$result); // now convert JSON into PHP array and traverse it $resultDecoded = json_decode($nu_result, true); $arr = array_pop($resultDecoded); array_walk_recursive($arr,function($e,$i) { if ($i == "price") { echo "price: ",$e,"\n"; } else if ($i == "origin_name") { echo "origin_name: ",$e,"\n\n"; } });
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uuNZU
function name:  (null)
number of ops:  21
compiled vars:  !0 = $result, !1 = $pat, !2 = $replace, !3 = $nu_result, !4 = $resultDecoded, !5 = $arr
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%7B%0A++++++++%22price%22%3A+%5B%0A++++++++++++%7B%0A++++++++++++++++%22price%22%3A+%222000%22%2C%0A++++++++++++++++%22origin_name%22%3A+%22JPN%22%2C%0A++++++++++++%7D%2C%0A++++++++++++%7B%0A++++++++++++++++%22price%22%3A+%225000%22%2C%0A++++++++++++++++%22origin_name%22%3A+%22USA%22%2C%0A++++++++++++%7D%0A++++++++%5D%0A+++%7D'
   17     1        ASSIGN                                                       !1, '%2F%28o.%2B%29%2C%2F'
   18     2        ASSIGN                                                       !2, '%241'
   19     3        FRAMELESS_ICALL_3                preg_replace        ~9      !1, !2
          4        OP_DATA                                                      !0
          5        ASSIGN                                                       !3, ~9
   22     6        INIT_FCALL                                                   'json_decode'
          7        SEND_VAR                                                     !3
          8        SEND_VAL                                                     <true>
          9        DO_ICALL                                             $11     
         10        ASSIGN                                                       !4, $11
   23    11        INIT_FCALL                                                   'array_pop'
         12        SEND_REF                                                     !4
         13        DO_ICALL                                             $13     
         14        ASSIGN                                                       !5, $13
   24    15        INIT_FCALL                                                   'array_walk_recursive'
         16        SEND_REF                                                     !5
         17        DECLARE_LAMBDA_FUNCTION                              ~15     [0]
   32    18        SEND_VAL                                                     ~15
   24    19        DO_ICALL                                                     
   33    20      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/uuNZU
function name:  {closure:/in/uuNZU:24}
number of ops:  14
compiled vars:  !0 = $e, !1 = $i
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   24     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   25     2        IS_EQUAL                                                     !1, 'price'
          3      > JMPZ                                                         ~2, ->8
   26     4    >   ECHO                                                         'price%3A+'
          5        ECHO                                                         !0
          6        ECHO                                                         '%0A'
   25     7      > JMP                                                          ->13
   29     8    >   IS_EQUAL                                                     !1, 'origin_name'
          9      > JMPZ                                                         ~3, ->13
   30    10    >   ECHO                                                         'origin_name%3A+'
         11        ECHO                                                         !0
         12        ECHO                                                         '%0A%0A'
   32    13    > > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
161.19 ms | 2562 KiB | 16 Q