3v4l.org

run code in 500+ 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:  45
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                                                   'strtolower'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                             $3      
          4        FRAMELESS_ICALL_3                preg_replace        ~4      <array>, <array>
          5        OP_DATA                                                      $3
          6        ASSIGN                                                       !1, ~4
    5     7        ECHO                                                         !1
    6     8        ECHO                                                         '%0A'
    7     9        ASSIGN                                                       !0, 'Fred+%2C+M.Sc'
    8    10        INIT_FCALL                                                   'strtolower'
         11        SEND_VAR                                                     !0
         12        DO_ICALL                                             $7      
         13        FRAMELESS_ICALL_3                preg_replace        ~8      <array>, <array>
         14        OP_DATA                                                      $7
         15        ASSIGN                                                       !1, ~8
    9    16        ECHO                                                         !1
   10    17        ECHO                                                         '%0A'
   11    18        ASSIGN                                                       !0, 'Fred+John+Doe+%2C+B.A'
   12    19        INIT_FCALL                                                   'strtolower'
         20        SEND_VAR                                                     !0
         21        DO_ICALL                                             $11     
         22        FRAMELESS_ICALL_3                preg_replace        ~12     <array>, <array>
         23        OP_DATA                                                      $11
         24        ASSIGN                                                       !1, ~12
   13    25        ECHO                                                         !1
   14    26        ECHO                                                         '%0A'
   15    27        ASSIGN                                                       !0, 'John+Doe'
   16    28        INIT_FCALL                                                   'strtolower'
         29        SEND_VAR                                                     !0
         30        DO_ICALL                                             $15     
         31        FRAMELESS_ICALL_3                preg_replace        ~16     <array>, <array>
         32        OP_DATA                                                      $15
         33        ASSIGN                                                       !1, ~16
   17    34        ECHO                                                         !1
   18    35        ECHO                                                         '%0A'
   19    36        ASSIGN                                                       !0, 'Fred'
   20    37        INIT_FCALL                                                   'strtolower'
         38        SEND_VAR                                                     !0
         39        DO_ICALL                                             $19     
         40        FRAMELESS_ICALL_3                preg_replace        ~20     <array>, <array>
         41        OP_DATA                                                      $19
         42        ASSIGN                                                       !1, ~20
   21    43        ECHO                                                         !1
   22    44      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
168.69 ms | 1862 KiB | 14 Q