3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( array('name' => 'Apple', 'json' => '{"type":"Fruit","sortOrder":2}'), array('name' => 'Potato', 'json' => '{"type":"Fruit","sortOrder":1}') ); $array = array_map(function (array $values) { $json = json_decode($values['json'], true); return $values + array('sortOrder' => $json['sortOrder']); }, $array); usort($array, function (array $a, array $b) { return $a['sortOrder'] - $b['sortOrder']; }); $array = array_map(function (array $values) { unset($values['sortOrder']); return $values; }, $array); var_dump($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C36Ur
function name:  (null)
number of ops:  22
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1        INIT_FCALL                                               'array_map'
          2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FC36Ur%3A9%240'
   12     3        SEND_VAL                                                 ~2
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
    9     6        ASSIGN                                                   !0, $3
   14     7        INIT_FCALL                                               'usort'
          8        SEND_REF                                                 !0
          9        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FC36Ur%3A14%241'
   16    10        SEND_VAL                                                 ~5
         11        DO_ICALL                                                 
   18    12        INIT_FCALL                                               'array_map'
         13        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FC36Ur%3A18%242'
   21    14        SEND_VAL                                                 ~7
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $8      
   18    17        ASSIGN                                                   !0, $8
   23    18        INIT_FCALL                                               'var_dump'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FC36Ur%3A9%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C36Ur
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $values, !1 = $json
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        INIT_FCALL                                               'json_decode'
          2        FETCH_DIM_R                                      ~2      !0, 'json'
          3        SEND_VAL                                                 ~2
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !1, $3
   11     7        FETCH_DIM_R                                      ~5      !1, 'sortOrder'
          8        INIT_ARRAY                                       ~6      ~5, 'sortOrder'
          9        ADD                                              ~7      !0, ~6
         10      > RETURN                                                   ~7
   12    11*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FC36Ur%3A9%240

Function %00%7Bclosure%7D%2Fin%2FC36Ur%3A14%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C36Ur
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        FETCH_DIM_R                                      ~2      !0, 'sortOrder'
          3        FETCH_DIM_R                                      ~3      !1, 'sortOrder'
          4        SUB                                              ~4      ~2, ~3
          5      > RETURN                                                   ~4
   16     6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FC36Ur%3A14%241

Function %00%7Bclosure%7D%2Fin%2FC36Ur%3A18%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C36Ur
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $values
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   19     1        UNSET_DIM                                                !0, 'sortOrder'
   20     2      > RETURN                                                   !0
   21     3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FC36Ur%3A18%242

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.81 ms | 1400 KiB | 21 Q