3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "The time is over. # its mean I'm need to die. Please help me. # Ghost. I am here alone. Sorry. # help yourself."; function lines(string $str): generator { $hPos = strpos($str, "#"); if($hPos !== false) { $dPos = strpos($str, ".", $hPos); if($dPos !== false) { yield substr($str, $hPos + 1, $dPos - $hPos - 1); foreach(lines(substr($str, $dPos + 1)) as $line) { yield $line; } } } } foreach(lines($str) as $line) { printf("%s\n", $line); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/Z8F20
function name:  (null)
number of ops:  13
compiled vars:  !0 = $str, !1 = $line
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'The+time+is+over.+%23+its+mean+I%27m+need+to+die.+Please+help+me.+%23+Ghost.+I+am+here+alone.+Sorry.+%23+help+yourself.'
   17     1        INIT_FCALL                                               'lines'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4      > FE_RESET_R                                       $4      $3, ->11
          5    > > FE_FETCH_R                                               $4, !1, ->11
   18     6    >   INIT_FCALL                                               'printf'
          7        SEND_VAL                                                 '%25s%0A'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
   17    10      > JMP                                                      ->5
         11    >   FE_FREE                                                  $4
   19    12      > RETURN                                                   1

Function lines:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 39
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 39
Branch analysis from position: 17
2 jumps found. (Code = 77) Position 1 = 35, Position 2 = 38
Branch analysis from position: 35
2 jumps found. (Code = 78) Position 1 = 36, Position 2 = 38
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
Branch analysis from position: 38
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 38
Branch analysis from position: 39
Branch analysis from position: 39
filename:       /in/Z8F20
function name:  lines
number of ops:  40
compiled vars:  !0 = $str, !1 = $hPos, !2 = $dPos, !3 = $line
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
    5     2        INIT_FCALL                                               'strpos'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 '%23'
          5        DO_ICALL                                         $4      
          6        ASSIGN                                                   !1, $4
    6     7        TYPE_CHECK                                  1018          !1
          8      > JMPZ                                                     ~6, ->39
    7     9    >   INIT_FCALL                                               'strpos'
         10        SEND_VAR                                                 !0
         11        SEND_VAL                                                 '.'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $7      
         14        ASSIGN                                                   !2, $7
    8    15        TYPE_CHECK                                  1018          !2
         16      > JMPZ                                                     ~9, ->39
    9    17    >   INIT_FCALL                                               'substr'
         18        SEND_VAR                                                 !0
         19        ADD                                              ~10     !1, 1
         20        SEND_VAL                                                 ~10
         21        SUB                                              ~11     !2, !1
         22        SUB                                              ~12     ~11, 1
         23        SEND_VAL                                                 ~12
         24        DO_ICALL                                         $13     
         25        YIELD                                                    $13
   10    26        INIT_FCALL_BY_NAME                                       'lines'
         27        INIT_FCALL                                               'substr'
         28        SEND_VAR                                                 !0
         29        ADD                                              ~15     !2, 1
         30        SEND_VAL                                                 ~15
         31        DO_ICALL                                         $16     
         32        SEND_VAR_NO_REF_EX                                       $16
         33        DO_FCALL                                      0  $17     
         34      > FE_RESET_R                                       $18     $17, ->38
         35    > > FE_FETCH_R                                               $18, !3, ->38
   11    36    >   YIELD                                                    !3
   10    37      > JMP                                                      ->35
         38    >   FE_FREE                                                  $18
   15    39    > > GENERATOR_RETURN                                         

End of function lines

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.96 ms | 1403 KiB | 20 Q