3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "This is my test case for an example"; function splitStrByWords($sentence, $wordCount=2) { $words = array_chunk( explode(' ', $sentence), $wordCount ); return array_map( 'implode', array_fill(0, sizeof($words), ' '), $words ); } var_export(splitStrByWords($string));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iphLT
function name:  (null)
number of ops:  8
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'This+is+my+test+case+for+an+example'
   16     1        INIT_FCALL                                               'var_export'
          2        INIT_FCALL                                               'splitstrbywords'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function splitstrbywords:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iphLT
function name:  splitStrByWords
number of ops:  24
compiled vars:  !0 = $sentence, !1 = $wordCount, !2 = $words
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      2
    6     2        INIT_FCALL                                               'array_chunk'
    7     3        INIT_FCALL                                               'explode'
          4        SEND_VAL                                                 '+'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $3      
          7        SEND_VAR                                                 $3
    8     8        SEND_VAR                                                 !1
    6     9        DO_ICALL                                         $4      
         10        ASSIGN                                                   !2, $4
   10    11        INIT_FCALL                                               'array_map'
   11    12        SEND_VAL                                                 'implode'
   12    13        INIT_FCALL                                               'array_fill'
         14        SEND_VAL                                                 0
         15        COUNT                                            ~6      !2
         16        SEND_VAL                                                 ~6
         17        SEND_VAL                                                 '+'
         18        DO_ICALL                                         $7      
         19        SEND_VAR                                                 $7
   13    20        SEND_VAR                                                 !2
   10    21        DO_ICALL                                         $8      
   13    22      > RETURN                                                   $8
   15    23*     > RETURN                                                   null

End of function splitstrbywords

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
186.38 ms | 1007 KiB | 19 Q