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(weight); $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 = 68
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 68
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 68
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 68
filename:       /in/nkitP
function name:  (null)
number of ops:  73
compiled vars:  !0 = $strings, !1 = $results, !2 = $string, !3 = $weight, !4 = $weight_string
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                                       $7      !0, ->68
          3    > > FE_FETCH_R                                               $7, !2, ->68
    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                                         $9      
         10        ASSIGN                                                   !4, $9
    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                                         $12     
         19        SEND_VAR                                                 $12
         20        SEND_VAL                                                 0
         21        DO_ICALL                                         $13     
         22        SEND_VAR                                                 $13
         23        DO_ICALL                                         $14     
         24        MUL                                              ~15     $14, 1000
         25        ASSIGN_OP                                     1          !3, ~15
   10    26        INIT_FCALL                                               'var_dump'
         27        FETCH_CONSTANT                                   ~17     'weight'
         28        SEND_VAL                                                 ~17
         29        DO_ICALL                                                 
   11    30        INIT_FCALL                                               'ord'
         31        INIT_FCALL                                               'substr'
         32        INIT_FCALL                                               'strtolower'
         33        SEND_VAR                                                 !4
         34        DO_ICALL                                         $19     
         35        SEND_VAR                                                 $19
         36        SEND_VAL                                                 1
         37        DO_ICALL                                         $20     
         38        SEND_VAR                                                 $20
         39        DO_ICALL                                         $21     
         40        MUL                                              ~22     $21, 100
         41        ASSIGN_OP                                     1          !3, ~22
   12    42        INIT_FCALL                                               'ord'
         43        INIT_FCALL                                               'substr'
         44        INIT_FCALL                                               'strtolower'
         45        SEND_VAR                                                 !4
         46        DO_ICALL                                         $24     
         47        SEND_VAR                                                 $24
         48        SEND_VAL                                                 2
         49        DO_ICALL                                         $25     
         50        SEND_VAR                                                 $25
         51        DO_ICALL                                         $26     
         52        MUL                                              ~27     $26, 10
         53        ASSIGN_OP                                     1          !3, ~27
   13    54        INIT_FCALL                                               'ord'
         55        INIT_FCALL                                               'substr'
         56        INIT_FCALL                                               'strtolower'
         57        SEND_VAR                                                 !4
         58        DO_ICALL                                         $29     
         59        SEND_VAR                                                 $29
         60        SEND_VAL                                                 3
         61        DO_ICALL                                         $30     
         62        SEND_VAR                                                 $30
         63        DO_ICALL                                         $31     
         64        ASSIGN_OP                                     1          !3, $31
   14    65        ASSIGN_DIM                                               !1
         66        OP_DATA                                                  !3
    5    67      > JMP                                                      ->3
         68    >   FE_FREE                                                  $7
   17    69        INIT_FCALL                                               'var_dump'
         70        SEND_VAR                                                 !1
         71        DO_ICALL                                                 
         72      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.91 ms | 1400 KiB | 23 Q