3v4l.org

run code in 300+ PHP versions simultaneously
<?php $elem1 = array('name' => 'one' , 'score' => 123); $elem2 = array('name' => 'twei', 'score' => 235); $elem3 = array('name' => 'yoo', 'score' => 12); $data = [$elem1, $elem2, $elem3]; var_dump(sortByValue($data, 'score')); function sortByValue($array, $value) { $temp = []; foreach($array as $i => $elem) { $temp[$i] = $elem[$value]; } arsort($temp); var_dump($temp); $data = []; foreach($temp as $elem) { $data[] = $elem; } return $data; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ye2SF
function name:  (null)
number of ops:  15
compiled vars:  !0 = $elem1, !1 = $elem2, !2 = $elem3, !3 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN                                                   !2, <array>
    7     3        INIT_ARRAY                                       ~7      !0
          4        ADD_ARRAY_ELEMENT                                ~7      !1
          5        ADD_ARRAY_ELEMENT                                ~7      !2
          6        ASSIGN                                                   !3, ~7
    8     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL_BY_NAME                                       'sortByValue'
          9        SEND_VAR_EX                                              !3
         10        SEND_VAL_EX                                              'score'
         11        DO_FCALL                                      0  $9      
         12        SEND_VAR                                                 $9
         13        DO_ICALL                                                 
   23    14      > RETURN                                                   1

Function sortbyvalue:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 23
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 23
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
Branch analysis from position: 10
filename:       /in/Ye2SF
function name:  sortByValue
number of ops:  26
compiled vars:  !0 = $array, !1 = $value, !2 = $temp, !3 = $elem, !4 = $i, !5 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        ASSIGN                                                   !2, <array>
   12     3      > FE_RESET_R                                       $7      !0, ->10
          4    > > FE_FETCH_R                                       ~8      $7, !3, ->10
          5    >   ASSIGN                                                   !4, ~8
   13     6        FETCH_DIM_R                                      ~11     !3, !1
          7        ASSIGN_DIM                                               !2, !4
          8        OP_DATA                                                  ~11
   12     9      > JMP                                                      ->4
         10    >   FE_FREE                                                  $7
   15    11        INIT_FCALL                                               'arsort'
         12        SEND_REF                                                 !2
         13        DO_ICALL                                                 
   16    14        INIT_FCALL                                               'var_dump'
         15        SEND_VAR                                                 !2
         16        DO_ICALL                                                 
   18    17        ASSIGN                                                   !5, <array>
   19    18      > FE_RESET_R                                       $15     !2, ->23
         19    > > FE_FETCH_R                                               $15, !3, ->23
   20    20    >   ASSIGN_DIM                                               !5
         21        OP_DATA                                                  !3
   19    22      > JMP                                                      ->19
         23    >   FE_FREE                                                  $15
   22    24      > RETURN                                                   !5
   23    25*     > RETURN                                                   null

End of function sortbyvalue

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
218.22 ms | 1400 KiB | 17 Q