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"; $start2 = 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)-$start2)*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/IbuuD
function name:  (null)
number of ops:  89
compiled vars:  !0 = $fruits, !1 = $content, !2 = $start, !3 = $pos, !4 = $start2, !5 = $count, !6 = $fruit, !7 = $arr_fruit, !8 = $SortCont
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, 'eaplp'
    6     2        INIT_FCALL                                               'microtime'
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $11     
          5        ASSIGN                                                   !2, $11
   13     6        INIT_FCALL                                               'array_search'
          7        INIT_FCALL                                               'sorted'
          8        SEND_VAR                                                 !1
          9        DO_FCALL                                      0  $13     
         10        SEND_VAR                                                 $13
         11        INIT_FCALL                                               'array_map'
         12        SEND_VAL                                                 'sorted'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $14     
         15        SEND_VAR                                                 $14
         16        DO_ICALL                                         $15     
         17        ASSIGN                                                   !3, $15
   15    18        TYPE_CHECK                                  1018          !3
         19      > JMPZ                                                     ~17, ->25
         20    >   FETCH_DIM_R                                      ~18     !0, !3
         21        NOP                                                      
         22        FAST_CONCAT                                      ~19     ~18, '+found.%0A'
         23        QM_ASSIGN                                        ~20     ~19
         24      > JMP                                                      ->26
         25    >   QM_ASSIGN                                        ~20     'not+found.%0A'
         26    >   ECHO                                                     ~20
   16    27        INIT_FCALL                                               'microtime'
         28        SEND_VAL                                                 <true>
         29        DO_ICALL                                         $21     
         30        SUB                                              ~22     $21, !2
         31        MUL                                              ~23     ~22, 100
         32        CONCAT                                           ~24     ~23, '%0A%0A'
         33        ECHO                                                     ~24
   19    34        ASSIGN                                                   !0, <array>
   20    35        ASSIGN                                                   !1, 'eaplp'
   22    36        INIT_FCALL                                               'microtime'
         37        SEND_VAL                                                 <true>
         38        DO_ICALL                                         $27     
         39        ASSIGN                                                   !4, $27
   23    40        INIT_FCALL                                               'str_split'
         41        SEND_VAR                                                 !1
         42        DO_ICALL                                         $29     
         43        ASSIGN                                                   !1, $29
   24    44        COUNT                                            ~31     !1
         45        ASSIGN                                                   !5, ~31
   26    46      > FE_RESET_R                                       $33     !0, ->81
         47    > > FE_FETCH_R                                               $33, !6, ->81
   27    48    >   INIT_FCALL                                               'str_split'
         49        SEND_VAR                                                 !6
         50        DO_ICALL                                         $34     
         51        ASSIGN                                                   !7, $34
   28    52        INIT_FCALL                                               'array_merge'
         53        INIT_FCALL                                               'array_intersect'
         54        SEND_VAR                                                 !7
         55        SEND_VAR                                                 !1
         56        DO_ICALL                                         $36     
         57        SEND_VAR                                                 $36
         58        INIT_FCALL                                               'array_diff'
         59        SEND_VAR                                                 !1
         60        SEND_VAR                                                 !7
         61        DO_ICALL                                         $37     
         62        SEND_VAR                                                 $37
         63        DO_ICALL                                         $38     
         64        ASSIGN                                                   !8, $38
   29    65        INIT_FCALL                                               'array_slice'
         66        SEND_VAR                                                 !8
         67        SEND_VAL                                                 0
         68        SEND_VAR                                                 !5
         69        DO_ICALL                                         $40     
         70        INIT_FCALL                                               'array_slice'
         71        SEND_VAR                                                 !7
         72        SEND_VAL                                                 0
         73        SEND_VAR                                                 !5
         74        DO_ICALL                                         $41     
         75        IS_EQUAL                                                 $40, $41
         76      > JMPZ                                                     ~42, ->80
   30    77    >   CONCAT                                           ~43     'match%3A+', !6
         78        CONCAT                                           ~44     ~43, '%0A'
         79        ECHO                                                     ~44
   26    80    > > JMP                                                      ->47
         81    >   FE_FREE                                                  $33
   34    82        INIT_FCALL                                               'microtime'
         83        SEND_VAL                                                 <true>
         84        DO_ICALL                                         $45     
         85        SUB                                              ~46     $45, !4
         86        MUL                                              ~47     ~46, 100
         87        ECHO                                                     ~47
   35    88      > RETURN                                                   1

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

End of function sorted

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.62 ms | 1407 KiB | 34 Q