3v4l.org

run code in 300+ PHP versions simultaneously
<?php function split_name($fullname) { $firstname = ""; $surname = ""; $pieces = explode(" ", $fullname); foreach ($pieces as $name) { if (ctype_upper(filter_var(str_replace("'", "", $name), FILTER_SANITIZE_STRING))) $surname .= $name." "; else $firstname .= $name. " "; } return array("firstname" => $firstname, "surname" => $surname); } $names = array("Jack David SMITH", "Pietro DE GIOVANNI", "Jane JOHNSON", "Matthew O'RILEY", "John-Paul JOHNSON"); $split = array_map("split_name", $names); print_r($split);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JXp2s
function name:  (null)
number of ops:  10
compiled vars:  !0 = $names, !1 = $split
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, <array>
   19     1        INIT_FCALL                                               'array_map'
          2        SEND_VAL                                                 'split_name'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !1, $3
   20     6        INIT_FCALL                                               'print_r'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function split_name:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 30
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 30
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 27
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/JXp2s
function name:  split_name
number of ops:  35
compiled vars:  !0 = $fullname, !1 = $firstname, !2 = $surname, !3 = $pieces, !4 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, ''
    5     2        ASSIGN                                                   !2, ''
    7     3        INIT_FCALL                                               'explode'
          4        SEND_VAL                                                 '+'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $7      
          7        ASSIGN                                                   !3, $7
    8     8      > FE_RESET_R                                       $9      !3, ->30
          9    > > FE_FETCH_R                                               $9, !4, ->30
    9    10    >   INIT_FCALL                                               'ctype_upper'
         11        INIT_FCALL                                               'filter_var'
         12        INIT_FCALL                                               'str_replace'
         13        SEND_VAL                                                 '%27'
         14        SEND_VAL                                                 ''
         15        SEND_VAR                                                 !4
         16        DO_ICALL                                         $10     
         17        SEND_VAR                                                 $10
         18        FETCH_CONSTANT                                   ~11     'FILTER_SANITIZE_STRING'
         19        SEND_VAL                                                 ~11
         20        DO_ICALL                                         $12     
         21        SEND_VAR                                                 $12
         22        DO_ICALL                                         $13     
         23      > JMPZ                                                     $13, ->27
   10    24    >   CONCAT                                           ~14     !4, '+'
         25        ASSIGN_OP                                     8          !2, ~14
    9    26      > JMP                                                      ->29
   12    27    >   CONCAT                                           ~16     !4, '+'
         28        ASSIGN_OP                                     8          !1, ~16
    8    29    > > JMP                                                      ->9
         30    >   FE_FREE                                                  $9
   14    31        INIT_ARRAY                                       ~18     !1, 'firstname'
         32        ADD_ARRAY_ELEMENT                                ~18     !2, 'surname'
         33      > RETURN                                                   ~18
   15    34*     > RETURN                                                   null

End of function split_name

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.36 ms | 1021 KiB | 19 Q