3v4l.org

run code in 300+ PHP versions simultaneously
<?php function split_nth($str, $delim, $n) { return array_map(function($p) use ($delim) { return implode($delim, $p); }, array_chunk(explode($delim, $str), $n)); } $array = split_nth("Atap Bocor AC Bagus Kursi bagus Meja Bagus", " ", 2); print_r($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9ZuXi
function name:  (null)
number of ops:  10
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   INIT_FCALL                                               'split_nth'
          1        SEND_VAL                                                 'Atap+Bocor+AC+Bagus+Kursi+bagus+Meja+Bagus'
          2        SEND_VAL                                                 '+'
          3        SEND_VAL                                                 2
          4        DO_FCALL                                      0  $1      
          5        ASSIGN                                                   !0, $1
   12     6        INIT_FCALL                                               'print_r'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function split_nth:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9ZuXi
function name:  split_nth
number of ops:  19
compiled vars:  !0 = $str, !1 = $delim, !2 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    5     3        INIT_FCALL                                               'array_map'
          4        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
          5        BIND_LEXICAL                                             ~3, !1
    7     6        SEND_VAL                                                 ~3
          7        INIT_FCALL                                               'array_chunk'
          8        INIT_FCALL                                               'explode'
          9        SEND_VAR                                                 !1
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $4      
         12        SEND_VAR                                                 $4
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                         $5      
         15        SEND_VAR                                                 $5
    5    16        DO_ICALL                                         $6      
    7    17      > RETURN                                                   $6
    8    18*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9ZuXi
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $p, !1 = $delim
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    6     2        INIT_FCALL                                               'implode'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6      > RETURN                                                   $2
    7     7*     > RETURN                                                   null

End of Dynamic Function 0

End of function split_nth

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.53 ms | 1022 KiB | 19 Q