3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '{ "example": "1", "example2": 2, "text": "3", "info": { "agent": 4, "sum": 5, "collection": [{ "Name": "6", "Pic": "7" }, { "Name": "8", "Pic": "9" }, { "Name": "10", "Pic": "11" }] } }'; $result = json_decode ($json, true); foreach($result as $key => $value){ if($key == 'info'){ $keys = array_keys($value['collection']); array_multisort( array_column($value['collection'], 'Pic'), SORT_DESC, SORT_NUMERIC, $value['collection'], $keys ); $value = array_combine($keys, $value['collection']); foreach($value as $val){ echo $val['Pic']." - ".$val['Name']."\n"; } } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 46
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 46
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 45
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 36, Position 2 = 44
Branch analysis from position: 36
2 jumps found. (Code = 78) Position 1 = 37, Position 2 = 44
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 44
Branch analysis from position: 45
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
filename:       /in/1jh0u
function name:  (null)
number of ops:  48
compiled vars:  !0 = $json, !1 = $result, !2 = $value, !3 = $key, !4 = $keys, !5 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%7B%0A%22example%22%3A+%221%22%2C%0A%22example2%22%3A+2%2C%0A%22text%22%3A+%223%22%2C%0A%22info%22%3A+%7B%0A++++%22agent%22%3A+4%2C%0A++++%22sum%22%3A+5%2C%0A++++%22collection%22%3A+%5B%7B%0A++++++++%22Name%22%3A+%226%22%2C%0A++++++++%22Pic%22%3A+%227%22%0A%09%09%7D%2C+%7B%0A%09%09%09%22Name%22%3A+%228%22%2C%0A%09%09%09%22Pic%22%3A+%229%22%0A%09%09%7D%2C+%7B%0A%09%09%09%22Name%22%3A+%2210%22%2C%0A%09%09%09%22Pic%22%3A+%2211%22%0A%09%09%7D%5D%0A+++++%7D%0A%7D'
   22     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $7      
          5        ASSIGN                                                   !1, $7
   23     6      > FE_RESET_R                                       $9      !1, ->46
          7    > > FE_FETCH_R                                       ~10     $9, !2, ->46
          8    >   ASSIGN                                                   !3, ~10
   24     9        IS_EQUAL                                                 !3, 'info'
         10      > JMPZ                                                     ~12, ->45
   25    11    >   INIT_FCALL                                               'array_keys'
         12        FETCH_DIM_R                                      ~13     !2, 'collection'
         13        SEND_VAL                                                 ~13
         14        DO_ICALL                                         $14     
         15        ASSIGN                                                   !4, $14
   26    16        INIT_FCALL                                               'array_multisort'
   27    17        INIT_FCALL                                               'array_column'
         18        FETCH_DIM_R                                      ~16     !2, 'collection'
         19        SEND_VAL                                                 ~16
         20        SEND_VAL                                                 'Pic'
         21        DO_ICALL                                         $17     
         22        SEND_VAL                                                 $17
         23        SEND_VAL                                                 3
         24        SEND_VAL                                                 1
         25        FETCH_DIM_W                                      $18     !2, 'collection'
         26        SEND_REF                                                 $18
         27        SEND_REF                                                 !4
         28        DO_ICALL                                                 
   29    29        INIT_FCALL                                               'array_combine'
         30        SEND_VAR                                                 !4
         31        FETCH_DIM_R                                      ~20     !2, 'collection'
         32        SEND_VAL                                                 ~20
         33        DO_ICALL                                         $21     
         34        ASSIGN                                                   !2, $21
   30    35      > FE_RESET_R                                       $23     !2, ->44
         36    > > FE_FETCH_R                                               $23, !5, ->44
   31    37    >   FETCH_DIM_R                                      ~24     !5, 'Pic'
         38        CONCAT                                           ~25     ~24, '+-+'
         39        FETCH_DIM_R                                      ~26     !5, 'Name'
         40        CONCAT                                           ~27     ~25, ~26
         41        CONCAT                                           ~28     ~27, '%0A'
         42        ECHO                                                     ~28
   30    43      > JMP                                                      ->36
         44    >   FE_FREE                                                  $23
   23    45    > > JMP                                                      ->7
         46    >   FE_FREE                                                  $9
   34    47      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.67 ms | 1400 KiB | 23 Q