3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = array('SS2014', 'SU2014','FW2014','SS2013','SU2013','FW2013'); $results = array(); foreach($strings as $string){ $weight = 0; $weight_string = preg_replace("/[^0-9a-zA-Z]/", "", $string); var_dump($weight_string); $weight += ord(substr(strtolower($weight_string), 0)) * 1000; var_dump($substr(strtolower($weight_string), 0)); $weight += ord(substr(strtolower($weight_string), 1)) * 100; $weight += ord(substr(strtolower($weight_string), 2)) * 10; $weight += ord(substr(strtolower($weight_string), 3)); $results[] = $weight; } var_dump($results);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 74
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 74
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 74
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 74
filename:       /in/vhlmM
function name:  (null)
number of ops:  79
compiled vars:  !0 = $strings, !1 = $results, !2 = $string, !3 = $weight, !4 = $weight_string, !5 = $substr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2      > FE_RESET_R                                       $8      !0, ->74
          3    > > FE_FETCH_R                                               $8, !2, ->74
    6     4    >   ASSIGN                                                   !3, 0
    7     5        INIT_FCALL                                               'preg_replace'
          6        SEND_VAL                                                 '%2F%5B%5E0-9a-zA-Z%5D%2F'
          7        SEND_VAL                                                 ''
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                         $10     
         10        ASSIGN                                                   !4, $10
    8    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !4
         13        DO_ICALL                                                 
    9    14        INIT_FCALL                                               'ord'
         15        INIT_FCALL                                               'substr'
         16        INIT_FCALL                                               'strtolower'
         17        SEND_VAR                                                 !4
         18        DO_ICALL                                         $13     
         19        SEND_VAR                                                 $13
         20        SEND_VAL                                                 0
         21        DO_ICALL                                         $14     
         22        SEND_VAR                                                 $14
         23        DO_ICALL                                         $15     
         24        MUL                                              ~16     $15, 1000
         25        ASSIGN_OP                                     1          !3, ~16
   10    26        INIT_FCALL                                               'var_dump'
         27        INIT_DYNAMIC_CALL                                        !5
         28        INIT_FCALL                                               'strtolower'
         29        SEND_VAR                                                 !4
         30        DO_ICALL                                         $18     
         31        SEND_VAR_NO_REF_EX                                       $18
         32        SEND_VAL_EX                                              0
         33        DO_FCALL                                      0  $19     
         34        SEND_VAR                                                 $19
         35        DO_ICALL                                                 
   11    36        INIT_FCALL                                               'ord'
         37        INIT_FCALL                                               'substr'
         38        INIT_FCALL                                               'strtolower'
         39        SEND_VAR                                                 !4
         40        DO_ICALL                                         $21     
         41        SEND_VAR                                                 $21
         42        SEND_VAL                                                 1
         43        DO_ICALL                                         $22     
         44        SEND_VAR                                                 $22
         45        DO_ICALL                                         $23     
         46        MUL                                              ~24     $23, 100
         47        ASSIGN_OP                                     1          !3, ~24
   12    48        INIT_FCALL                                               'ord'
         49        INIT_FCALL                                               'substr'
         50        INIT_FCALL                                               'strtolower'
         51        SEND_VAR                                                 !4
         52        DO_ICALL                                         $26     
         53        SEND_VAR                                                 $26
         54        SEND_VAL                                                 2
         55        DO_ICALL                                         $27     
         56        SEND_VAR                                                 $27
         57        DO_ICALL                                         $28     
         58        MUL                                              ~29     $28, 10
         59        ASSIGN_OP                                     1          !3, ~29
   13    60        INIT_FCALL                                               'ord'
         61        INIT_FCALL                                               'substr'
         62        INIT_FCALL                                               'strtolower'
         63        SEND_VAR                                                 !4
         64        DO_ICALL                                         $31     
         65        SEND_VAR                                                 $31
         66        SEND_VAL                                                 3
         67        DO_ICALL                                         $32     
         68        SEND_VAR                                                 $32
         69        DO_ICALL                                         $33     
         70        ASSIGN_OP                                     1          !3, $33
   14    71        ASSIGN_DIM                                               !1
         72        OP_DATA                                                  !3
    5    73      > JMP                                                      ->3
         74    >   FE_FREE                                                  $8
   17    75        INIT_FCALL                                               'var_dump'
         76        SEND_VAR                                                 !1
         77        DO_ICALL                                                 
         78      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
191.41 ms | 1400 KiB | 23 Q