3v4l.org

run code in 300+ PHP versions simultaneously
<?php function oldTextual($steamid) { $result = 'Invalid input.'; if (!preg_match('([a-zA-Z])', $steamid) && strlen($steamid) === 17) { // 64-bit int $acc_id = bcsub($steamid, '76561197960265728'); $result = 'STEAM_0:'; if ($acc_id % 2 === 0) $result .= '0:'; else $result .= '1:'; $result .= bcdiv($acc_id, '2', 0); } if (substr($steamid, 0, 2) === "U:") { // New textual format $split = explode(':', $steamid); $result = 'STEAM_0:'; $z = (int)$split[2]; if ($z % 2 === 0) $result .= '0:'; else $result .= '1:'; $acc_id = bcdiv($z, '2', 0); $result .= $acc_id; } return $result; } function newTextual($steamid) { $result = 'Invalid input.'; if (substr($steamid, 0, 6) === 'STEAM_') { // Old textual format $split = explode(':', $steamid); $y = $split[1]; $z = $split[2]; $acc_id = bcadd(bcmul($z, '2'), $y); $result = 'U:1:' . $acc_id; } if (!preg_match('([a-zA-Z])', $steamid) && strlen($steamid) === 17) { // 64-bit int $acc_id = bcsub($steamid, '76561197960265728'); $result = 'U:1:' . $acc_id; } return $result; } function numeric($steamid) { $result = 'Invalid input.'; if (substr($steamid, 0, 6) === 'STEAM_') { // Old textual format $split = explode(':', $steamid); $commid = bcmul($split[2], '2'); if ($split[1] === '1') $commid = bcadd($commid, '1'); $result = bcadd($commid, '76561197960265728'); } if (substr($steamid, 0, 2) === "U:") { // New textual format $filter = str_replace(array('[', ']'), '', $steamid); $split = explode(':', $filter); $result = bcadd($split[2], '76561197960265728'); } return $result; } $steamid64 = '76561198074715892'; $steamid32 = 'STEAM_0:0:57225082'; $steamid3 = 'U:1:114450164'; echo oldTextual($steamid64) . '<br>'; echo oldTextual($steamid3) . '<br>'; echo newTextual($steamid64) . '<br>'; echo newTextual($steamid32) . '<br>'; echo 'http://steamcommunity.com/profiles/' . numeric($steamid32) . '<br>'; echo 'http://steamcommunity.com/profiles/' . numeric($steamid3);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/USdlZ
function name:  (null)
number of ops:  35
compiled vars:  !0 = $steamid64, !1 = $steamid32, !2 = $steamid3
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   76     0  E >   ASSIGN                                                   !0, '76561198074715892'
   77     1        ASSIGN                                                   !1, 'STEAM_0%3A0%3A57225082'
   78     2        ASSIGN                                                   !2, 'U%3A1%3A114450164'
   81     3        INIT_FCALL                                               'oldtextual'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $6      
          6        CONCAT                                           ~7      $6, '%3Cbr%3E'
          7        ECHO                                                     ~7
   82     8        INIT_FCALL                                               'oldtextual'
          9        SEND_VAR                                                 !2
         10        DO_FCALL                                      0  $8      
         11        CONCAT                                           ~9      $8, '%3Cbr%3E'
         12        ECHO                                                     ~9
   84    13        INIT_FCALL                                               'newtextual'
         14        SEND_VAR                                                 !0
         15        DO_FCALL                                      0  $10     
         16        CONCAT                                           ~11     $10, '%3Cbr%3E'
         17        ECHO                                                     ~11
   85    18        INIT_FCALL                                               'newtextual'
         19        SEND_VAR                                                 !1
         20        DO_FCALL                                      0  $12     
         21        CONCAT                                           ~13     $12, '%3Cbr%3E'
         22        ECHO                                                     ~13
   87    23        INIT_FCALL                                               'numeric'
         24        SEND_VAR                                                 !1
         25        DO_FCALL                                      0  $14     
         26        CONCAT                                           ~15     'http%3A%2F%2Fsteamcommunity.com%2Fprofiles%2F', $14
         27        CONCAT                                           ~16     ~15, '%3Cbr%3E'
         28        ECHO                                                     ~16
   88    29        INIT_FCALL                                               'numeric'
         30        SEND_VAR                                                 !2
         31        DO_FCALL                                      0  $17     
         32        CONCAT                                           ~18     'http%3A%2F%2Fsteamcommunity.com%2Fprofiles%2F', $17
         33        ECHO                                                     ~18
         34      > RETURN                                                   1

Function oldtextual:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 30
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 59
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 51
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 59
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 59
Branch analysis from position: 37
Branch analysis from position: 59
Branch analysis from position: 30
Branch analysis from position: 11
filename:       /in/USdlZ
function name:  oldTextual
number of ops:  61
compiled vars:  !0 = $steamid, !1 = $result, !2 = $acc_id, !3 = $split, !4 = $z
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, 'Invalid+input.'
    5     2        INIT_FCALL                                               'preg_match'
          3        SEND_VAL                                                 '%28%5Ba-zA-Z%5D%29'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $6      
          6        BOOL_NOT                                         ~7      $6
          7      > JMPZ_EX                                          ~7      ~7, ->11
          8    >   STRLEN                                           ~8      !0
          9        IS_IDENTICAL                                     ~9      ~8, 17
         10        BOOL                                             ~7      ~9
         11    > > JMPZ                                                     ~7, ->30
    6    12    >   INIT_FCALL_BY_NAME                                       'bcsub'
         13        SEND_VAR_EX                                              !0
         14        SEND_VAL_EX                                              '76561197960265728'
         15        DO_FCALL                                      0  $10     
         16        ASSIGN                                                   !2, $10
    7    17        ASSIGN                                                   !1, 'STEAM_0%3A'
    9    18        MOD                                              ~13     !2, 2
         19        IS_IDENTICAL                                             ~13, 0
         20      > JMPZ                                                     ~14, ->23
   10    21    >   ASSIGN_OP                                     8          !1, '0%3A'
         22      > JMP                                                      ->24
   12    23    >   ASSIGN_OP                                     8          !1, '1%3A'
   14    24    >   INIT_FCALL_BY_NAME                                       'bcdiv'
         25        SEND_VAR_EX                                              !2
         26        SEND_VAL_EX                                              '2'
         27        SEND_VAL_EX                                              0
         28        DO_FCALL                                      0  $17     
         29        ASSIGN_OP                                     8          !1, $17
   17    30    >   INIT_FCALL                                               'substr'
         31        SEND_VAR                                                 !0
         32        SEND_VAL                                                 0
         33        SEND_VAL                                                 2
         34        DO_ICALL                                         $19     
         35        IS_IDENTICAL                                             $19, 'U%3A'
         36      > JMPZ                                                     ~20, ->59
   18    37    >   INIT_FCALL                                               'explode'
         38        SEND_VAL                                                 '%3A'
         39        SEND_VAR                                                 !0
         40        DO_ICALL                                         $21     
         41        ASSIGN                                                   !3, $21
   19    42        ASSIGN                                                   !1, 'STEAM_0%3A'
   21    43        FETCH_DIM_R                                      ~24     !3, 2
         44        CAST                                          4  ~25     ~24
         45        ASSIGN                                                   !4, ~25
   23    46        MOD                                              ~27     !4, 2
         47        IS_IDENTICAL                                             ~27, 0
         48      > JMPZ                                                     ~28, ->51
   24    49    >   ASSIGN_OP                                     8          !1, '0%3A'
         50      > JMP                                                      ->52
   26    51    >   ASSIGN_OP                                     8          !1, '1%3A'
   28    52    >   INIT_FCALL_BY_NAME                                       'bcdiv'
         53        SEND_VAR_EX                                              !4
         54        SEND_VAL_EX                                              '2'
         55        SEND_VAL_EX                                              0
         56        DO_FCALL                                      0  $31     
         57        ASSIGN                                                   !2, $31
   29    58        ASSIGN_OP                                     8          !1, !2
   32    59    > > RETURN                                                   !1
   33    60*     > RETURN                                                   null

End of function oldtextual

Function newtextual:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 29
Branch analysis from position: 9
2 jumps found. (Code = 46) Position 1 = 35, Position 2 = 38
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 46
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
Branch analysis from position: 38
Branch analysis from position: 29
filename:       /in/USdlZ
function name:  newTextual
number of ops:  48
compiled vars:  !0 = $steamid, !1 = $result, !2 = $split, !3 = $y, !4 = $z, !5 = $acc_id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
   36     1        ASSIGN                                                   !1, 'Invalid+input.'
   38     2        INIT_FCALL                                               'substr'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 0
          5        SEND_VAL                                                 6
          6        DO_ICALL                                         $7      
          7        IS_IDENTICAL                                             $7, 'STEAM_'
          8      > JMPZ                                                     ~8, ->29
   39     9    >   INIT_FCALL                                               'explode'
         10        SEND_VAL                                                 '%3A'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $9      
         13        ASSIGN                                                   !2, $9
   40    14        FETCH_DIM_R                                      ~11     !2, 1
         15        ASSIGN                                                   !3, ~11
   41    16        FETCH_DIM_R                                      ~13     !2, 2
         17        ASSIGN                                                   !4, ~13
   42    18        INIT_FCALL_BY_NAME                                       'bcadd'
         19        INIT_FCALL_BY_NAME                                       'bcmul'
         20        SEND_VAR_EX                                              !4
         21        SEND_VAL_EX                                              '2'
         22        DO_FCALL                                      0  $15     
         23        SEND_VAR_NO_REF_EX                                       $15
         24        SEND_VAR_EX                                              !3
         25        DO_FCALL                                      0  $16     
         26        ASSIGN                                                   !5, $16
   43    27        CONCAT                                           ~18     'U%3A1%3A', !5
         28        ASSIGN                                                   !1, ~18
   46    29    >   INIT_FCALL                                               'preg_match'
         30        SEND_VAL                                                 '%28%5Ba-zA-Z%5D%29'
         31        SEND_VAR                                                 !0
         32        DO_ICALL                                         $20     
         33        BOOL_NOT                                         ~21     $20
         34      > JMPZ_EX                                          ~21     ~21, ->38
         35    >   STRLEN                                           ~22     !0
         36        IS_IDENTICAL                                     ~23     ~22, 17
         37        BOOL                                             ~21     ~23
         38    > > JMPZ                                                     ~21, ->46
   47    39    >   INIT_FCALL_BY_NAME                                       'bcsub'
         40        SEND_VAR_EX                                              !0
         41        SEND_VAL_EX                                              '76561197960265728'
         42        DO_FCALL                                      0  $24     
         43        ASSIGN                                                   !5, $24
   48    44        CONCAT                                           ~26     'U%3A1%3A', !5
         45        ASSIGN                                                   !1, ~26
   51    46    > > RETURN                                                   !1
   52    47*     > RETURN                                                   null

End of function newtextual

Function numeric:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 34
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 29
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 59
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 59
Branch analysis from position: 29
Branch analysis from position: 34
filename:       /in/USdlZ
function name:  numeric
number of ops:  61
compiled vars:  !0 = $steamid, !1 = $result, !2 = $split, !3 = $commid, !4 = $filter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   RECV                                             !0      
   55     1        ASSIGN                                                   !1, 'Invalid+input.'
   57     2        INIT_FCALL                                               'substr'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 0
          5        SEND_VAL                                                 6
          6        DO_ICALL                                         $6      
          7        IS_IDENTICAL                                             $6, 'STEAM_'
          8      > JMPZ                                                     ~7, ->34
   58     9    >   INIT_FCALL                                               'explode'
         10        SEND_VAL                                                 '%3A'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $8      
         13        ASSIGN                                                   !2, $8
   59    14        INIT_FCALL_BY_NAME                                       'bcmul'
         15        CHECK_FUNC_ARG                                           
         16        FETCH_DIM_FUNC_ARG                               $10     !2, 2
         17        SEND_FUNC_ARG                                            $10
         18        SEND_VAL_EX                                              '2'
         19        DO_FCALL                                      0  $11     
         20        ASSIGN                                                   !3, $11
   61    21        FETCH_DIM_R                                      ~13     !2, 1
         22        IS_IDENTICAL                                             ~13, '1'
         23      > JMPZ                                                     ~14, ->29
   62    24    >   INIT_FCALL_BY_NAME                                       'bcadd'
         25        SEND_VAR_EX                                              !3
         26        SEND_VAL_EX                                              '1'
         27        DO_FCALL                                      0  $15     
         28        ASSIGN                                                   !3, $15
   64    29    >   INIT_FCALL_BY_NAME                                       'bcadd'
         30        SEND_VAR_EX                                              !3
         31        SEND_VAL_EX                                              '76561197960265728'
         32        DO_FCALL                                      0  $17     
         33        ASSIGN                                                   !1, $17
   67    34    >   INIT_FCALL                                               'substr'
         35        SEND_VAR                                                 !0
         36        SEND_VAL                                                 0
         37        SEND_VAL                                                 2
         38        DO_ICALL                                         $19     
         39        IS_IDENTICAL                                             $19, 'U%3A'
         40      > JMPZ                                                     ~20, ->59
   68    41    >   INIT_FCALL                                               'str_replace'
         42        SEND_VAL                                                 <array>
         43        SEND_VAL                                                 ''
         44        SEND_VAR                                                 !0
         45        DO_ICALL                                         $21     
         46        ASSIGN                                                   !4, $21
   69    47        INIT_FCALL                                               'explode'
         48        SEND_VAL                                                 '%3A'
         49        SEND_VAR                                                 !4
         50        DO_ICALL                                         $23     
         51        ASSIGN                                                   !2, $23
   70    52        INIT_FCALL_BY_NAME                                       'bcadd'
         53        CHECK_FUNC_ARG                                           
         54        FETCH_DIM_FUNC_ARG                               $25     !2, 2
         55        SEND_FUNC_ARG                                            $25
         56        SEND_VAL_EX                                              '76561197960265728'
         57        DO_FCALL                                      0  $26     
         58        ASSIGN                                                   !1, $26
   73    59    > > RETURN                                                   !1
   74    60*     > RETURN                                                   null

End of function numeric

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.23 ms | 1419 KiB | 27 Q