3v4l.org

run code in 300+ PHP versions simultaneously
<?php $name = 'John Doe, Ph.D'; $get_name = preg_replace(array('/^([a-z]+(?:\s+[a-z]+)?).*$/', '/\s+/'), array('$1', '_'), strtolower($name)); echo $get_name; echo "\n"; $name = 'Fred , M.Sc'; $get_name = preg_replace(array('/^([a-z]+(?:\s+[a-z]+)?).*$/', '/\s+/'), array('$1', '_'), strtolower($name)); echo $get_name; echo "\n"; $name = 'Fred John Doe , B.A'; $get_name = preg_replace(array('/^([a-z]+(?:\s+[a-z]+)?).*$/', '/\s+/'), array('$1', '_'), strtolower($name)); echo $get_name; echo "\n"; $name = 'John Doe'; $get_name = preg_replace(array('/^([a-z]+(?:\s+[a-z]+)?).*$/', '/\s+/'), array('$1', '_'), strtolower($name)); echo $get_name; echo "\n"; $name = 'Fred'; $get_name = preg_replace(array('/^([a-z]+(?:\s+[a-z]+)?).*$/', '/\s+/'), array('$1', '_'), strtolower($name)); echo $get_name;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i560r
function name:  (null)
number of ops:  60
compiled vars:  !0 = $name, !1 = $get_name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'John+Doe%2C+Ph.D'
    4     1        INIT_FCALL                                               'preg_replace'
          2        SEND_VAL                                                 <array>
          3        SEND_VAL                                                 <array>
          4        INIT_FCALL                                               'strtolower'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $3      
          7        SEND_VAR                                                 $3
          8        DO_ICALL                                         $4      
          9        ASSIGN                                                   !1, $4
    5    10        ECHO                                                     !1
    6    11        ECHO                                                     '%0A'
    7    12        ASSIGN                                                   !0, 'Fred+%2C+M.Sc'
    8    13        INIT_FCALL                                               'preg_replace'
         14        SEND_VAL                                                 <array>
         15        SEND_VAL                                                 <array>
         16        INIT_FCALL                                               'strtolower'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $7      
         19        SEND_VAR                                                 $7
         20        DO_ICALL                                         $8      
         21        ASSIGN                                                   !1, $8
    9    22        ECHO                                                     !1
   10    23        ECHO                                                     '%0A'
   11    24        ASSIGN                                                   !0, 'Fred+John+Doe+%2C+B.A'
   12    25        INIT_FCALL                                               'preg_replace'
         26        SEND_VAL                                                 <array>
         27        SEND_VAL                                                 <array>
         28        INIT_FCALL                                               'strtolower'
         29        SEND_VAR                                                 !0
         30        DO_ICALL                                         $11     
         31        SEND_VAR                                                 $11
         32        DO_ICALL                                         $12     
         33        ASSIGN                                                   !1, $12
   13    34        ECHO                                                     !1
   14    35        ECHO                                                     '%0A'
   15    36        ASSIGN                                                   !0, 'John+Doe'
   16    37        INIT_FCALL                                               'preg_replace'
         38        SEND_VAL                                                 <array>
         39        SEND_VAL                                                 <array>
         40        INIT_FCALL                                               'strtolower'
         41        SEND_VAR                                                 !0
         42        DO_ICALL                                         $15     
         43        SEND_VAR                                                 $15
         44        DO_ICALL                                         $16     
         45        ASSIGN                                                   !1, $16
   17    46        ECHO                                                     !1
   18    47        ECHO                                                     '%0A'
   19    48        ASSIGN                                                   !0, 'Fred'
   20    49        INIT_FCALL                                               'preg_replace'
         50        SEND_VAL                                                 <array>
         51        SEND_VAL                                                 <array>
         52        INIT_FCALL                                               'strtolower'
         53        SEND_VAR                                                 !0
         54        DO_ICALL                                         $19     
         55        SEND_VAR                                                 $19
         56        DO_ICALL                                         $20     
         57        ASSIGN                                                   !1, $20
   21    58        ECHO                                                     !1
   22    59      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.63 ms | 1405 KiB | 17 Q