3v4l.org

run code in 500+ 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 = 27
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 27
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 24
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/JXp2s
function name:  split_name
number of ops:  32
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, ->27
          9    > > FE_FETCH_R                                                   $9, !4, ->27
    9    10    >   INIT_FCALL                                                   'ctype_upper'
         11        INIT_FCALL                                                   'filter_var'
         12        FRAMELESS_ICALL_3                str_replace         ~10     '%27', ''
         13        OP_DATA                                                      !4
         14        SEND_VAL                                                     ~10
         15        FETCH_CONSTANT                                       ~11     'FILTER_SANITIZE_STRING'
         16        SEND_VAL                                                     ~11
         17        DO_ICALL                                             $12     
         18        SEND_VAR                                                     $12
         19        DO_ICALL                                             $13     
         20      > JMPZ                                                         $13, ->24
   10    21    >   CONCAT                                               ~14     !4, '+'
         22        ASSIGN_OP                                         8          !2, ~14
    9    23      > JMP                                                          ->26
   12    24    >   CONCAT                                               ~16     !4, '+'
         25        ASSIGN_OP                                         8          !1, ~16
    8    26    > > JMP                                                          ->9
         27    >   FE_FREE                                                      $9
   14    28        INIT_ARRAY                                           ~18     !1, 'firstname'
         29        ADD_ARRAY_ELEMENT                                    ~18     !2, 'surname'
         30      > RETURN                                                       ~18
   15    31*     > RETURN                                                       null

End of function split_name

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.34 ms | 2905 KiB | 18 Q