3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr=array( 'ACTION' => 'getsupportdepartments', 'RESULT' => 'success', 'TOTALRESULTS' => 2, 'DEPARTMENTS' => array( 'DEPARTMENT' => array( 'ID' => 2, 'NAME' => 'Sales', 'AWAITINGREPLY' => 5, 'OPENTICKETS' => 5 ), 'DEPARTMENT1' => array( 'ID' => 1, 'NAME' => 'Support', 'AWAITINGREPLY' => 15, 'OPENTICKETS' => 15))); function sortDepts(array &$arr,$sort="desc") { if($sort=="desc") usort($arr["DEPARTMENTS"],function($a,$b){ return $b["AWAITINGREPLY"]-$a["AWAITINGREPLY"]; }); else usort($arr["DEPARTMENTS"],function($a,$b){ return $a["AWAITINGREPLY"]-$b["AWAITINGREPLY"]; }); return $arr; } print_r(sortDepts($arr,"desc")); print_r(sortDepts($arr,"asc"));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mV1P5
function name:  (null)
number of ops:  16
compiled vars:  !0 = $arr
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
   30     1        INIT_FCALL                                                   'print_r'
          2        INIT_FCALL                                                   'sortdepts'
          3        SEND_REF                                                     !0
          4        SEND_VAL                                                     'desc'
          5        DO_FCALL                                          0  $2      
          6        SEND_VAR                                                     $2
          7        DO_ICALL                                                     
   31     8        INIT_FCALL                                                   'print_r'
          9        INIT_FCALL                                                   'sortdepts'
         10        SEND_REF                                                     !0
         11        SEND_VAL                                                     'asc'
         12        DO_FCALL                                          0  $4      
         13        SEND_VAR                                                     $4
         14        DO_ICALL                                                     
         15      > RETURN                                                       1

Function sortdepts:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mV1P5
function name:  sortDepts
number of ops:  19
compiled vars:  !0 = $arr, !1 = $sort
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   RECV                                                 !0      
          1        RECV_INIT                                            !1      'desc'
   20     2        IS_EQUAL                                                     !1, 'desc'
          3      > JMPZ                                                         ~2, ->11
   21     4    >   INIT_FCALL                                                   'usort'
          5        FETCH_DIM_W                                          $3      !0, 'DEPARTMENTS'
          6        SEND_REF                                                     $3
          7        DECLARE_LAMBDA_FUNCTION                              ~4      [0]
   23     8        SEND_VAL                                                     ~4
   21     9        DO_ICALL                                                     
   20    10      > JMP                                                          ->17
   25    11    >   INIT_FCALL                                                   'usort'
         12        FETCH_DIM_W                                          $6      !0, 'DEPARTMENTS'
         13        SEND_REF                                                     $6
         14        DECLARE_LAMBDA_FUNCTION                              ~7      [1]
   27    15        SEND_VAL                                                     ~7
   25    16        DO_ICALL                                                     
   28    17    > > RETURN                                                       !0
   29    18*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mV1P5
function name:  {closure:sortDepts():21}
number of ops:  7
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   21     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   22     2        FETCH_DIM_R                                          ~2      !1, 'AWAITINGREPLY'
          3        FETCH_DIM_R                                          ~3      !0, 'AWAITINGREPLY'
          4        SUB                                                  ~4      ~2, ~3
          5      > RETURN                                                       ~4
   23     6*     > RETURN                                                       null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mV1P5
function name:  {closure:sortDepts():25}
number of ops:  7
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   25     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   26     2        FETCH_DIM_R                                          ~2      !0, 'AWAITINGREPLY'
          3        FETCH_DIM_R                                          ~3      !1, 'AWAITINGREPLY'
          4        SUB                                                  ~4      ~2, ~3
          5      > RETURN                                                       ~4
   27     6*     > RETURN                                                       null

End of Dynamic Function 1

End of function sortdepts

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
172.41 ms | 3247 KiB | 17 Q