3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '{ "errors": [ [ { "id": "login1", "error": "Invalid" }, { "id": "login2", "error": "Invalid" }, { "id": "login3", "error": "Invalid" } ], [], [ { "id": "login10", "error": "Invalid" }, { "id": "login11", "error": "Invalid" } ] ] }'; $array = json_decode($json, true); $errors = []; foreach($array['errors'] AS $subarray) { $errors = array_merge_recursive($errors, $subarray); } print_r($errors);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/JgqgO
function name:  (null)
number of ops:  21
compiled vars:  !0 = $json, !1 = $array, !2 = $errors, !3 = $subarray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7B%0A++%22errors%22%3A+%5B%0A++++%5B%0A++++++%7B%0A++++++++%22id%22%3A+%22login1%22%2C%0A++++++++%22error%22%3A+%22Invalid%22%0A++++++%7D%2C%0A++++++%7B%0A++++++++%22id%22%3A+%22login2%22%2C%0A++++++++%22error%22%3A+%22Invalid%22%0A++++++%7D%2C%0A++++++%7B%0A++++++++%22id%22%3A+%22login3%22%2C%0A++++++++%22error%22%3A+%22Invalid%22%0A++++++%7D%0A++++%5D%2C%0A++++%5B%5D%2C%0A++++%5B%0A++++++%7B%0A++++++++%22id%22%3A+%22login10%22%2C+%0A++++++++%22error%22%3A+%22Invalid%22%0A++++++%7D%2C%0A++++++%7B%0A++++++++%22id%22%3A+%22login11%22%2C+%0A++++++++%22error%22%3A+%22Invalid%22%0A++++++%7D%0A++++%5D%0A++%5D%0A%7D'
   34     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
   36     6        ASSIGN                                                   !2, <array>
   37     7        FETCH_DIM_R                                      ~8      !1, 'errors'
          8      > FE_RESET_R                                       $9      ~8, ->16
          9    > > FE_FETCH_R                                               $9, !3, ->16
   38    10    >   INIT_FCALL                                               'array_merge_recursive'
         11        SEND_VAR                                                 !2
         12        SEND_VAR                                                 !3
         13        DO_ICALL                                         $10     
         14        ASSIGN                                                   !2, $10
   37    15      > JMP                                                      ->9
         16    >   FE_FREE                                                  $9
   41    17        INIT_FCALL                                               'print_r'
         18        SEND_VAR                                                 !2
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
292.73 ms | 1013 KiB | 16 Q