3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array1 = array( 'cover.xhtml', 'title.xhtml', 'copyright.xhtml', 'dedication.xhtml', 'toc_brief.xhtml', 'toc.xhtml', 'ch02_1.xhtml', 'ch02_2.xhtml', 'ch02_3.xhtml', 'ch02_4.xhtml', 'ch02_5.xhtml', 'ch02_6.xhtml', 'ch02_7.xhtml', 'ch02_8.xhtml', 'ch02_9.xhtml', 'ch02_10.xhtml' ); $array2 = array( '', 'title.xhtml', 'copyright.xhtml', 'dedication.xhtml', 'ch02_2.xhtml', 'ch02_2#454.xhtml', 'ch02_4.xhtml', 'ch02_1.xhtml', 'ch02_11.xhtml', 'ch02_12.xhtml', '' ); $customOrder = array_flip([ 'cover', 'title', 'copyright', 'dedication', 'toc_brief', 'toc', 'ch' ]); $uniqueFiltered = array_unique(array_filter(array_merge($array1, $array2))); array_multisort( array_map(fn($v) => $customOrder[strtok($v, '.012345789')], $uniqueFiltered), str_replace('#', '_', $uniqueFiltered), SORT_NATURAL, $uniqueFiltered ); var_export($uniqueFiltered);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kiU09
function name:  (null)
number of ops:  35
compiled vars:  !0 = $array1, !1 = $array2, !2 = $customOrder, !3 = $uniqueFiltered
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   22     1        ASSIGN                                                       !1, <array>
   35     2        INIT_FCALL                                                   'array_flip'
   36     3        SEND_VAL                                                     <array>
   35     4        DO_ICALL                                             $6      
          5        ASSIGN                                                       !2, $6
   45     6        INIT_FCALL                                                   'array_unique'
          7        INIT_FCALL                                                   'array_filter'
          8        INIT_FCALL                                                   'array_merge'
          9        SEND_VAR                                                     !0
         10        SEND_VAR                                                     !1
         11        DO_ICALL                                             $8      
         12        SEND_VAR                                                     $8
         13        DO_ICALL                                             $9      
         14        SEND_VAR                                                     $9
         15        DO_ICALL                                             $10     
         16        ASSIGN                                                       !3, $10
   46    17        INIT_FCALL                                                   'array_multisort'
   47    18        INIT_FCALL                                                   'array_map'
         19        DECLARE_LAMBDA_FUNCTION                              ~12     [0]
         20        BIND_LEXICAL                                                 ~12, !2
         21        SEND_VAL                                                     ~12
         22        SEND_VAR                                                     !3
         23        DO_ICALL                                             $13     
         24        SEND_VAL                                                     $13
   48    25        FRAMELESS_ICALL_3                str_replace         ~14     '%23', '_'
         26        OP_DATA                                                      !3
         27        SEND_VAL                                                     ~14
   49    28        SEND_VAL                                                     6
   50    29        SEND_REF                                                     !3
   46    30        DO_ICALL                                                     
   52    31        INIT_FCALL                                                   'var_export'
         32        SEND_VAR                                                     !3
         33        DO_ICALL                                                     
         34      > 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/kiU09
function name:  {closure:/in/kiU09:47}
number of ops:  9
compiled vars:  !0 = $v, !1 = $customOrder
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   47     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
          2        INIT_FCALL                                                   'strtok'
          3        SEND_VAR                                                     !0
          4        SEND_VAL                                                     '.012345789'
          5        DO_ICALL                                             $2      
          6        FETCH_DIM_R                                          ~3      !1, $2
          7      > RETURN                                                       ~3
          8*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.57 ms | 1962 KiB | 22 Q