3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fruits = array("apple","orange","papaya","grape","apple juice", "applecurd"); $content = "eaplp"; $start = microtime(true); function sorted($s) { $a = str_split($s); sort($a); return implode("", $a); } $pos = array_search(sorted($content), array_map("sorted", $fruits)); echo ($pos !== false) ? "$fruits[$pos] found.\n" : "not found.\n"; echo (microtime(true)-$start)*100 . "\n\n"; $fruits = array("apple","orange","papaya","grape","apple juice", "applecurd"); $content = "eaplp"; $start = microtime(true); $content = str_split($content); $count = count($content); Foreach($fruits as $fruit){ $arr_fruit = str_split($fruit); $SortCont = array_merge(array_intersect($arr_fruit, $content), array_diff($content, $arr_fruit)); If(array_slice($SortCont, 0, $count) == array_slice($arr_fruit, 0, $count)){ Echo "match: " . $fruit ."\n"; } } echo (microtime(true)-$start)*100;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 25
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 77) Position 1 = 47, Position 2 = 81
Branch analysis from position: 47
2 jumps found. (Code = 78) Position 1 = 48, Position 2 = 81
Branch analysis from position: 48
2 jumps found. (Code = 43) Position 1 = 77, Position 2 = 80
Branch analysis from position: 77
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
Branch analysis from position: 80
Branch analysis from position: 81
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 81
Branch analysis from position: 25
2 jumps found. (Code = 77) Position 1 = 47, Position 2 = 81
Branch analysis from position: 47
Branch analysis from position: 81
filename:       /in/H6UNd
function name:  (null)
number of ops:  89
compiled vars:  !0 = $fruits, !1 = $content, !2 = $start, !3 = $pos, !4 = $count, !5 = $fruit, !6 = $arr_fruit, !7 = $SortCont
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, 'eaplp'
    5     2        INIT_FCALL                                               'microtime'
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $10     
          5        ASSIGN                                                   !2, $10
   12     6        INIT_FCALL                                               'array_search'
          7        INIT_FCALL                                               'sorted'
          8        SEND_VAR                                                 !1
          9        DO_FCALL                                      0  $12     
         10        SEND_VAR                                                 $12
         11        INIT_FCALL                                               'array_map'
         12        SEND_VAL                                                 'sorted'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $13     
         15        SEND_VAR                                                 $13
         16        DO_ICALL                                         $14     
         17        ASSIGN                                                   !3, $14
   14    18        TYPE_CHECK                                  1018          !3
         19      > JMPZ                                                     ~16, ->25
         20    >   FETCH_DIM_R                                      ~17     !0, !3
         21        NOP                                                      
         22        FAST_CONCAT                                      ~18     ~17, '+found.%0A'
         23        QM_ASSIGN                                        ~19     ~18
         24      > JMP                                                      ->26
         25    >   QM_ASSIGN                                        ~19     'not+found.%0A'
         26    >   ECHO                                                     ~19
   15    27        INIT_FCALL                                               'microtime'
         28        SEND_VAL                                                 <true>
         29        DO_ICALL                                         $20     
         30        SUB                                              ~21     $20, !2
         31        MUL                                              ~22     ~21, 100
         32        CONCAT                                           ~23     ~22, '%0A%0A'
         33        ECHO                                                     ~23
   18    34        ASSIGN                                                   !0, <array>
   19    35        ASSIGN                                                   !1, 'eaplp'
   20    36        INIT_FCALL                                               'microtime'
         37        SEND_VAL                                                 <true>
         38        DO_ICALL                                         $26     
         39        ASSIGN                                                   !2, $26
   21    40        INIT_FCALL                                               'str_split'
         41        SEND_VAR                                                 !1
         42        DO_ICALL                                         $28     
         43        ASSIGN                                                   !1, $28
   22    44        COUNT                                            ~30     !1
         45        ASSIGN                                                   !4, ~30
   24    46      > FE_RESET_R                                       $32     !0, ->81
         47    > > FE_FETCH_R                                               $32, !5, ->81
   25    48    >   INIT_FCALL                                               'str_split'
         49        SEND_VAR                                                 !5
         50        DO_ICALL                                         $33     
         51        ASSIGN                                                   !6, $33
   26    52        INIT_FCALL                                               'array_merge'
         53        INIT_FCALL                                               'array_intersect'
         54        SEND_VAR                                                 !6
         55        SEND_VAR                                                 !1
         56        DO_ICALL                                         $35     
         57        SEND_VAR                                                 $35
         58        INIT_FCALL                                               'array_diff'
         59        SEND_VAR                                                 !1
         60        SEND_VAR                                                 !6
         61        DO_ICALL                                         $36     
         62        SEND_VAR                                                 $36
         63        DO_ICALL                                         $37     
         64        ASSIGN                                                   !7, $37
   27    65        INIT_FCALL                                               'array_slice'
         66        SEND_VAR                                                 !7
         67        SEND_VAL                                                 0
         68        SEND_VAR                                                 !4
         69        DO_ICALL                                         $39     
         70        INIT_FCALL                                               'array_slice'
         71        SEND_VAR                                                 !6
         72        SEND_VAL                                                 0
         73        SEND_VAR                                                 !4
         74        DO_ICALL                                         $40     
         75        IS_EQUAL                                                 $39, $40
         76      > JMPZ                                                     ~41, ->80
   28    77    >   CONCAT                                           ~42     'match%3A+', !5
         78        CONCAT                                           ~43     ~42, '%0A'
         79        ECHO                                                     ~43
   24    80    > > JMP                                                      ->47
         81    >   FE_FREE                                                  $32
   32    82        INIT_FCALL                                               'microtime'
         83        SEND_VAL                                                 <true>
         84        DO_ICALL                                         $44     
         85        SUB                                              ~45     $44, !2
         86        MUL                                              ~46     ~45, 100
         87        ECHO                                                     ~46
   33    88      > RETURN                                                   1

Function sorted:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/H6UNd
function name:  sorted
number of ops:  14
compiled vars:  !0 = $s, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        INIT_FCALL                                               'str_split'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !1, $2
    8     5        INIT_FCALL                                               'sort'
          6        SEND_REF                                                 !1
          7        DO_ICALL                                                 
    9     8        INIT_FCALL                                               'implode'
          9        SEND_VAL                                                 ''
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $5      
         12      > RETURN                                                   $5
   10    13*     > RETURN                                                   null

End of function sorted

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.48 ms | 954 KiB | 35 Q