3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '15_some_text_or_numbers'; var_dump( sscanf($string, '%d')[0], (int) $string, preg_replace('/^\d+\K.*/', '', $string), preg_match('/^\d+/', $string, $m) ? $m[0] : null, strstr($string . '_', '_', true), // append an underscore to the input if not guaranteed explode('_', $string, 2)[0], // the limit parameter prevents needeless explosions strtok($string, '_') );
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 25
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZYCR4
function name:  (null)
number of ops:  48
compiled vars:  !0 = $string, !1 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '15_some_text_or_numbers'
    5     1        INIT_FCALL                                               'var_dump'
    6     2        INIT_FCALL                                               'sscanf'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 '%25d'
          5        DO_ICALL                                         $3      
          6        FETCH_DIM_R                                      ~4      $3, 0
          7        SEND_VAL                                                 ~4
    7     8        CAST                                          4  ~5      !0
          9        SEND_VAL                                                 ~5
    8    10        INIT_FCALL                                               'preg_replace'
         11        SEND_VAL                                                 '%2F%5E%5Cd%2B%5CK.%2A%2F'
         12        SEND_VAL                                                 ''
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $6      
         15        SEND_VAR                                                 $6
    9    16        INIT_FCALL                                               'preg_match'
         17        SEND_VAL                                                 '%2F%5E%5Cd%2B%2F'
         18        SEND_VAR                                                 !0
         19        SEND_REF                                                 !1
         20        DO_ICALL                                         $7      
         21      > JMPZ                                                     $7, ->25
         22    >   FETCH_DIM_R                                      ~8      !1, 0
         23        QM_ASSIGN                                        ~9      ~8
         24      > JMP                                                      ->26
         25    >   QM_ASSIGN                                        ~9      null
         26    >   SEND_VAL                                                 ~9
   10    27        INIT_FCALL                                               'strstr'
         28        CONCAT                                           ~10     !0, '_'
         29        SEND_VAL                                                 ~10
         30        SEND_VAL                                                 '_'
         31        SEND_VAL                                                 <true>
         32        DO_ICALL                                         $11     
         33        SEND_VAR                                                 $11
   11    34        INIT_FCALL                                               'explode'
         35        SEND_VAL                                                 '_'
         36        SEND_VAR                                                 !0
         37        SEND_VAL                                                 2
         38        DO_ICALL                                         $12     
         39        FETCH_DIM_R                                      ~13     $12, 0
         40        SEND_VAL                                                 ~13
   12    41        INIT_FCALL                                               'strtok'
         42        SEND_VAR                                                 !0
         43        SEND_VAL                                                 '_'
         44        DO_ICALL                                         $14     
         45        SEND_VAR                                                 $14
    5    46        DO_ICALL                                                 
   13    47      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
218.06 ms | 1027 KiB | 20 Q