3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( 'Google', 'Facebook', 'Twitter', 'Slack', 'Twilio', 'Bookface' ); $cachedLength = 0; foreach ($array as $value) { $currentLength = strlen($value); if ($currentLength > $cachedLength) { $longest = [$value]; $cachedLength = $currentLength; } elseif ($currentLength == $cachedLength) { $longest[] = $value; } } var_export($longest);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 17
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 17
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 16
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/SmAr1
function name:  (null)
number of ops:  22
compiled vars:  !0 = $array, !1 = $cachedLength, !2 = $value, !3 = $currentLength, !4 = $longest
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   10     1        ASSIGN                                                   !1, 0
   12     2      > FE_RESET_R                                       $7      !0, ->17
          3    > > FE_FETCH_R                                               $7, !2, ->17
   13     4    >   STRLEN                                           ~8      !2
          5        ASSIGN                                                   !3, ~8
   14     6        IS_SMALLER                                               !1, !3
          7      > JMPZ                                                     ~10, ->12
   15     8    >   INIT_ARRAY                                       ~11     !2
          9        ASSIGN                                                   !4, ~11
   16    10        ASSIGN                                                   !1, !3
   14    11      > JMP                                                      ->16
   17    12    >   IS_EQUAL                                                 !3, !1
         13      > JMPZ                                                     ~14, ->16
   18    14    >   ASSIGN_DIM                                               !4
         15        OP_DATA                                                  !2
   12    16    > > JMP                                                      ->3
         17    >   FE_FREE                                                  $7
   21    18        INIT_FCALL                                               'var_export'
         19        SEND_VAR                                                 !4
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.95 ms | 1010 KiB | 14 Q