3v4l.org

run code in 300+ PHP versions simultaneously
<?php $var = (array) 'hey there'; $var2 = ensure_numeric_array( 'hey there' ); print_r($var); print_r($var2); function ensure_numeric_array( $vart ) { if ( ! isset( $vart[0] ) ) { return [ $vart ]; } return $vart; } ///////
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WNYPp
function name:  (null)
number of ops:  13
compiled vars:  !0 = $var, !1 = $var2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   CAST                                          7  ~2      'hey+there'
          1        ASSIGN                                                   !0, ~2
    4     2        INIT_FCALL_BY_NAME                                       'ensure_numeric_array'
          3        SEND_VAL_EX                                              'hey+there'
          4        DO_FCALL                                      0  $4      
          5        ASSIGN                                                   !1, $4
    6     6        INIT_FCALL                                               'print_r'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
    7     9        INIT_FCALL                                               'print_r'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                                 
   27    12      > RETURN                                                   1

Function ensure_numeric_array:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WNYPp
function name:  ensure_numeric_array
number of ops:  8
compiled vars:  !0 = $vart
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        ISSET_ISEMPTY_DIM_OBJ                         0  ~1      !0, 0
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ                                                     ~2, ->6
   12     4    >   INIT_ARRAY                                       ~3      !0
          5      > RETURN                                                   ~3
   15     6    > > RETURN                                                   !0
   16     7*     > RETURN                                                   null

End of function ensure_numeric_array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.91 ms | 1387 KiB | 15 Q