3v4l.org

run code in 300+ 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}
number of ops:  29
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, ->27
   50    15        INIT_FCALL                                               'strnatcmp'
         16        INIT_FCALL                                               'str_replace'
         17        SEND_VAL                                                 '%23'
         18        SEND_VAL                                                 '_'
         19        INIT_ARRAY                                       ~9      !0
         20        ADD_ARRAY_ELEMENT                                ~9      !1
         21        SEND_VAL                                                 ~9
         22        DO_ICALL                                         $10     
         23        SEND_UNPACK                                              $10
         24        CHECK_UNDEF_ARGS                                         
         25        DO_ICALL                                         $11     
         26        QM_ASSIGN                                        ~8      $11
         27      > RETURN                                                   ~8
   51    28*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.35 ms | 1016 KiB | 22 Q