3v4l.org

run code in 300+ PHP versions simultaneously
<?php $line = "HELLO WORLD HOW ARE YOU I AM JUST FINE THANKS"; $plan = [9, 20]; var_dump(plan_split($line, $plan)); function plan_split(string $line, array $plan) : array { $plan[] = strlen($line); // last substring $start = 0; $parsed = []; foreach ($plan as $end) { $parsed[] = substr($line, $start, $end); $start += $end; } return $parsed; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dbpM4
function name:  (null)
number of ops:  10
compiled vars:  !0 = $line, !1 = $plan
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, 'HELLO++++WORLD+HOW+ARE+YOU+++I+AM+JUST+FINE+THANKS'
    5     1        ASSIGN                                                   !1, <array>
    7     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL_BY_NAME                                       'plan_split'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
   19     9      > RETURN                                                   1

Function plan_split:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 18
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 18
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/dbpM4
function name:  plan_split
number of ops:  23
compiled vars:  !0 = $line, !1 = $plan, !2 = $start, !3 = $parsed, !4 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        STRLEN                                           ~6      !0
          3        ASSIGN_DIM                                               !1
          4        OP_DATA                                                  ~6
   12     5        ASSIGN                                                   !2, 0
   13     6        ASSIGN                                                   !3, <array>
   14     7      > FE_RESET_R                                       $9      !1, ->18
          8    > > FE_FETCH_R                                               $9, !4, ->18
   15     9    >   INIT_FCALL                                               'substr'
         10        SEND_VAR                                                 !0
         11        SEND_VAR                                                 !2
         12        SEND_VAR                                                 !4
         13        DO_ICALL                                         $11     
         14        ASSIGN_DIM                                               !3
         15        OP_DATA                                                  $11
   16    16        ASSIGN_OP                                     1          !2, !4
   14    17      > JMP                                                      ->8
         18    >   FE_FREE                                                  $9
   18    19        VERIFY_RETURN_TYPE                                       !3
         20      > RETURN                                                   !3
   19    21*       VERIFY_RETURN_TYPE                                       
         22*     > RETURN                                                   null

End of function plan_split

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.11 ms | 1396 KiB | 17 Q