3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = ['0000', '000000', '000']; function getzeros($val) { $highest = 0; $position = 0; $answer = ''; foreach($val as $key => $value){ if($value != '') { if (strlen($value) > $highest) { $answer = $value; $highest = strlen($value); $position = $key; } } } echo "The longest string was '" . $answer . "', with a length of " . strlen($answer) . ", at index " . $position; } getzeros($a);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/48Vac
function name:  (null)
number of ops:  5
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   21     1        INIT_FCALL                                               'getzeros'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   1

Function getzeros:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 17
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 17
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 16
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/48Vac
function name:  getzeros
number of ops:  26
compiled vars:  !0 = $val, !1 = $highest, !2 = $position, !3 = $answer, !4 = $value, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        ASSIGN                                                   !1, 0
    7     2        ASSIGN                                                   !2, 0
    8     3        ASSIGN                                                   !3, ''
    9     4      > FE_RESET_R                                       $9      !0, ->17
          5    > > FE_FETCH_R                                       ~10     $9, !4, ->17
          6    >   ASSIGN                                                   !5, ~10
   10     7        IS_NOT_EQUAL                                             !4, ''
          8      > JMPZ                                                     ~12, ->16
   11     9    >   STRLEN                                           ~13     !4
         10        IS_SMALLER                                               !1, ~13
         11      > JMPZ                                                     ~14, ->16
   12    12    >   ASSIGN                                                   !3, !4
   13    13        STRLEN                                           ~16     !4
         14        ASSIGN                                                   !1, ~16
   14    15        ASSIGN                                                   !2, !5
    9    16    > > JMP                                                      ->5
         17    >   FE_FREE                                                  $9
   18    18        CONCAT                                           ~19     'The+longest+string+was+%27', !3
         19        CONCAT                                           ~20     ~19, '%27%2C+with+a+length+of+'
         20        STRLEN                                           ~21     !3
         21        CONCAT                                           ~22     ~20, ~21
         22        CONCAT                                           ~23     ~22, '%2C+at+index+'
         23        CONCAT                                           ~24     ~23, !2
         24        ECHO                                                     ~24
   19    25      > RETURN                                                   null

End of function getzeros

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
259.75 ms | 1012 KiB | 14 Q