3v4l.org

run code in 300+ PHP versions simultaneously
<?php if ( ! defined('PHP_EOL')) { define('PHP_EOL', "\n"); } function normalise($string) { preg_match('~[0-9]+[a-z]+$~i', $string, $match); if ( ! isset($match[0])) { return false; } return strtoupper($match[0]); } $tests = array( 'Deu123456tx', 'Deu-12345tx', '12de45232gb', ); foreach ($tests as $test) { echo normalise($test), PHP_EOL; } /* 123456TX 12345TX 45232GB */
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 1, Position 2 = 5
Branch analysis from position: 1
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
Branch analysis from position: 5
filename:       /in/qUl0o
function name:  (null)
number of ops:  16
compiled vars:  !0 = $tests, !1 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E > > JMPZ                                                     <false>, ->5
    3     1    >   INIT_FCALL                                               'define'
          2        SEND_VAL                                                 'PHP_EOL'
          3        SEND_VAL                                                 '%0A'
          4        DO_ICALL                                                 
   17     5    >   ASSIGN                                                   !0, <array>
   23     6      > FE_RESET_R                                       $4      !0, ->14
          7    > > FE_FETCH_R                                               $4, !1, ->14
   24     8    >   INIT_FCALL                                               'normalise'
          9        SEND_VAR                                                 !1
         10        DO_FCALL                                      0  $5      
         11        ECHO                                                     $5
         12        ECHO                                                     '%0A'
   23    13      > JMP                                                      ->7
         14    >   FE_FREE                                                  $4
   31    15      > RETURN                                                   1

Function normalise:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qUl0o
function name:  normalise
number of ops:  16
compiled vars:  !0 = $string, !1 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1        INIT_FCALL                                               'preg_match'
          2        SEND_VAL                                                 '%7E%5B0-9%5D%2B%5Ba-z%5D%2B%24%7Ei'
          3        SEND_VAR                                                 !0
          4        SEND_REF                                                 !1
          5        DO_ICALL                                                 
   10     6        ISSET_ISEMPTY_DIM_OBJ                         0  ~3      !1, 0
          7        BOOL_NOT                                         ~4      ~3
          8      > JMPZ                                                     ~4, ->10
   11     9    > > RETURN                                                   <false>
   14    10    >   INIT_FCALL                                               'strtoupper'
         11        FETCH_DIM_R                                      ~5      !1, 0
         12        SEND_VAL                                                 ~5
         13        DO_ICALL                                         $6      
         14      > RETURN                                                   $6
   15    15*     > RETURN                                                   null

End of function normalise

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.12 ms | 1403 KiB | 20 Q