3v4l.org

run code in 300+ PHP versions simultaneously
<?php function splitname($input) { $input = trim($input); if ( strlen($input) < 1 ) return array( 0 => null, 1 => null ); $input = explode(' ', $input); if ( count($input) < 2 ) return array( 0 => $input[0], 1 => null ); $lastname = end($input); unset($input[count($input) - 1]); $firstname = implode(' ', $input); return array( 0 => $firstname, 1 => $lastname ); } echo var_dump(splitname(' aasd fef')); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u2a6T
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'splitname'
          2        SEND_VAL                                                 '+aasd+fef'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                         $1      
          6        ECHO                                                     $1
   22     7      > RETURN                                                   1

Function splitname:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u2a6T
function name:  splitname
number of ops:  37
compiled vars:  !0 = $input, !1 = $lastname, !2 = $firstname
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'trim'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !0, $3
    6     5        STRLEN                                           ~5      !0
          6        IS_SMALLER                                               ~5, 1
          7      > JMPZ                                                     ~6, ->9
          8    > > RETURN                                                   <array>
    8     9    >   INIT_FCALL                                               'explode'
         10        SEND_VAL                                                 '+'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $7      
         13        ASSIGN                                                   !0, $7
   10    14        COUNT                                            ~9      !0
         15        IS_SMALLER                                               ~9, 2
         16      > JMPZ                                                     ~10, ->21
         17    >   FETCH_DIM_R                                      ~11     !0, 0
         18        INIT_ARRAY                                       ~12     ~11, 0
         19        ADD_ARRAY_ELEMENT                                ~12     null, 1
         20      > RETURN                                                   ~12
   12    21    >   INIT_FCALL                                               'end'
         22        SEND_REF                                                 !0
         23        DO_ICALL                                         $13     
         24        ASSIGN                                                   !1, $13
   14    25        COUNT                                            ~15     !0
         26        SUB                                              ~16     ~15, 1
         27        UNSET_DIM                                                !0, ~16
   16    28        INIT_FCALL                                               'implode'
         29        SEND_VAL                                                 '+'
         30        SEND_VAR                                                 !0
         31        DO_ICALL                                         $17     
         32        ASSIGN                                                   !2, $17
   18    33        INIT_ARRAY                                       ~19     !2, 0
         34        ADD_ARRAY_ELEMENT                                ~19     !1, 1
         35      > RETURN                                                   ~19
   19    36*     > RETURN                                                   null

End of function splitname

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.25 ms | 1403 KiB | 24 Q