3v4l.org

run code in 300+ PHP versions simultaneously
<?php $lines = [ 'Alice Sandy', 'Alice Nanami', 'James Watt', 'Alice Monica', 'Johann Gauss', 'Cooper Alice', ]; $needle = 'Alice'; foreach($lines as $index => &$line) { if ($needle === strstr($line, ' ', true)) { // check whole first word if (!isset($firstOccurrence)) { $firstOccurrence =& $line; } else { $firstOccurrence .= strstr($line, ' '); unset($lines[$index]); } } } var_export($lines);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 3, Position 2 = 24
Branch analysis from position: 3
2 jumps found. (Code = 126) Position 1 = 4, Position 2 = 24
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 23
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 23
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/hOoYV
function name:  (null)
number of ops:  29
compiled vars:  !0 = $lines, !1 = $needle, !2 = $line, !3 = $index, !4 = $firstOccurrence
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   12     1        ASSIGN                                                   !1, 'Alice'
   13     2      > FE_RESET_RW                                      $7      !0, ->24
          3    > > FE_FETCH_RW                                      ~8      $7, !2, ->24
          4    >   ASSIGN                                                   !3, ~8
   14     5        INIT_FCALL                                               'strstr'
          6        SEND_VAR                                                 !2
          7        SEND_VAL                                                 '+'
          8        SEND_VAL                                                 <true>
          9        DO_ICALL                                         $10     
         10        IS_IDENTICAL                                             !1, $10
         11      > JMPZ                                                     ~11, ->23
   15    12    >   ISSET_ISEMPTY_CV                                 ~12     !4
         13        BOOL_NOT                                         ~13     ~12
         14      > JMPZ                                                     ~13, ->17
   16    15    >   ASSIGN_REF                                               !4, !2
   15    16      > JMP                                                      ->23
   18    17    >   INIT_FCALL                                               'strstr'
         18        SEND_VAR                                                 !2
         19        SEND_VAL                                                 '+'
         20        DO_ICALL                                         $15     
         21        ASSIGN_OP                                     8          !4, $15
   19    22        UNSET_DIM                                                !0, !3
   13    23    > > JMP                                                      ->3
         24    >   FE_FREE                                                  $7
   23    25        INIT_FCALL                                               'var_export'
         26        SEND_VAR                                                 !0
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.96 ms | 1012 KiB | 15 Q