3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = Array ( '0' => array ( 'tenure' => '1 year to less than 2 years' ), '1' => array ( 'tenure' => '10 years to less than 15 years' ), '2' => array ( 'tenure' => '15 years or more' ), '3' => array ( 'tenure' => '2 years to less than 5 years' ), '4' => array ( 'tenure' => '5 years to less than 10 years' ) ); $res=[]; array_walk($arr, function($v, $k) use (&$res){ $key = substr($v['tenure'], 0, strspn($v['tenure'], "0123456789")); $res[$key] = $v; }); ksort($res); print_r($res);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cOEXE
function name:  (null)
number of ops:  15
compiled vars:  !0 = $arr, !1 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   32     1        ASSIGN                                                   !1, <array>
   33     2        INIT_FCALL                                               'array_walk'
          3        SEND_REF                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
          5        BIND_LEXICAL                                             ~4, !1
   36     6        SEND_VAL                                                 ~4
   33     7        DO_ICALL                                                 
   37     8        INIT_FCALL                                               'ksort'
          9        SEND_REF                                                 !1
         10        DO_ICALL                                                 
   38    11        INIT_FCALL                                               'print_r'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
         14      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cOEXE
function name:  {closure}
number of ops:  18
compiled vars:  !0 = $v, !1 = $k, !2 = $res, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   34     3        INIT_FCALL                                               'substr'
          4        FETCH_DIM_R                                      ~4      !0, 'tenure'
          5        SEND_VAL                                                 ~4
          6        SEND_VAL                                                 0
          7        INIT_FCALL                                               'strspn'
          8        FETCH_DIM_R                                      ~5      !0, 'tenure'
          9        SEND_VAL                                                 ~5
         10        SEND_VAL                                                 '0123456789'
         11        DO_ICALL                                         $6      
         12        SEND_VAR                                                 $6
         13        DO_ICALL                                         $7      
         14        ASSIGN                                                   !3, $7
   35    15        ASSIGN_DIM                                               !2, !3
         16        OP_DATA                                                  !0
   36    17      > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.2 ms | 1005 KiB | 18 Q