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))); usort( $uniqueFiltered, fn($a, $b) => $customOrder[strtok($a, '.012345789')] <=> $customOrder[strtok($b, '.012345789')] ?: strnatcmp(...str_replace('#', '_', [$a, $b])) ); var_export($uniqueFiltered);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Zl6QE
function name:  (null)
number of ops:  27
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                                                   'usort'
   47    18        SEND_REF                                                     !3
   48    19        DECLARE_LAMBDA_FUNCTION                              ~12     [0]
         20        BIND_LEXICAL                                                 ~12, !2
   51    21        SEND_VAL                                                     ~12
   46    22        DO_ICALL                                                     
   52    23        INIT_FCALL                                                   'var_export'
         24        SEND_VAR                                                     !3
         25        DO_ICALL                                                     
         26      > 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/Zl6QE
function name:  {closure:/in/Zl6QE:48}
number of ops:  26
compiled vars:  !0 = $a, !1 = $b, !2 = $customOrder
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   48     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        BIND_STATIC                                                  !2
   49     3        INIT_FCALL                                                   'strtok'
          4        SEND_VAR                                                     !0
          5        SEND_VAL                                                     '.012345789'
          6        DO_ICALL                                             $3      
          7        FETCH_DIM_R                                          ~4      !2, $3
          8        INIT_FCALL                                                   'strtok'
          9        SEND_VAR                                                     !1
         10        SEND_VAL                                                     '.012345789'
         11        DO_ICALL                                             $5      
         12        FETCH_DIM_R                                          ~6      !2, $5
         13        SPACESHIP                                            ~7      ~4, ~6
         14        JMP_SET                                              ~8      ~7, ->24
   50    15        INIT_FCALL                                                   'strnatcmp'
         16        INIT_ARRAY                                           ~9      !0
         17        ADD_ARRAY_ELEMENT                                    ~9      !1
         18        FRAMELESS_ICALL_3                str_replace         ~10     '%23', '_'
         19        OP_DATA                                                      ~9
         20        SEND_UNPACK                                                  ~10
         21        CHECK_UNDEF_ARGS                                             
         22        DO_ICALL                                             $11     
         23        QM_ASSIGN                                            ~8      $11
         24      > RETURN                                                       ~8
   51    25*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
161.78 ms | 1950 KiB | 21 Q