3v4l.org

run code in 300+ PHP versions simultaneously
<?php function wordSafeSplit(string $text, int $pieces = 2): array { $maxLength = intdiv(strlen($text), $pieces); return preg_split( "~.{0,$maxLength}\K\s~s", $text, $pieces ); } $text = "The Quick : Brown Fox Jumped Over The Lazy / Dog"; var_export(wordSafeSplit($text));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HlLH6
function name:  (null)
number of ops:  8
compiled vars:  !0 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, 'The+Quick+%3A+Brown+Fox+Jumped+Over+The+Lazy+%2F+Dog'
   14     1        INIT_FCALL                                               'var_export'
          2        INIT_FCALL                                               'wordsafesplit'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function wordsafesplit:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HlLH6
function name:  wordSafeSplit
number of ops:  20
compiled vars:  !0 = $text, !1 = $pieces, !2 = $maxLength
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      2
    5     2        INIT_FCALL                                               'intdiv'
          3        STRLEN                                           ~3      !0
          4        SEND_VAL                                                 ~3
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $4      
          7        ASSIGN                                                   !2, $4
    6     8        INIT_FCALL                                               'preg_split'
    7     9        ROPE_INIT                                     3  ~7      '%7E.%7B0%2C'
         10        ROPE_ADD                                      1  ~7      ~7, !2
         11        ROPE_END                                      2  ~6      ~7, '%7D%5CK%5Cs%7Es'
         12        SEND_VAL                                                 ~6
    8    13        SEND_VAR                                                 !0
    9    14        SEND_VAR                                                 !1
    6    15        DO_ICALL                                         $9      
    9    16        VERIFY_RETURN_TYPE                                       $9
         17      > RETURN                                                   $9
   11    18*       VERIFY_RETURN_TYPE                                       
         19*     > RETURN                                                   null

End of function wordsafesplit

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.92 ms | 1016 KiB | 17 Q