3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = ['0000', '00', '000000']; function getzeros($val) { $highest = 0; $position = 0; foreach($val as $key => $value){ if($value != '') { if (strlen($value) > $highest) { $highest = strlen($value); $position = $key; } } } Return array("highest" => $highest, "position" => $position); } $max = getzeros($a); Echo $max["highest"] . " " . $max["position"] . " " . $a[$max["position"]];
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/42RWn
function name:  (null)
number of ops:  15
compiled vars:  !0 = $a, !1 = $max
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   19     1        INIT_FCALL                                               'getzeros'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
   20     5        FETCH_DIM_R                                      ~5      !1, 'highest'
          6        CONCAT                                           ~6      ~5, '+'
          7        FETCH_DIM_R                                      ~7      !1, 'position'
          8        CONCAT                                           ~8      ~6, ~7
          9        CONCAT                                           ~9      ~8, '+'
         10        FETCH_DIM_R                                      ~10     !1, 'position'
         11        FETCH_DIM_R                                      ~11     !0, ~10
         12        CONCAT                                           ~12     ~9, ~11
         13        ECHO                                                     ~12
         14      > RETURN                                                   1

Function getzeros:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 15
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 14
Branch analysis from position: 14
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/42RWn
function name:  getzeros
number of ops:  20
compiled vars:  !0 = $val, !1 = $highest, !2 = $position, !3 = $value, !4 = $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      > FE_RESET_R                                       $7      !0, ->15
          4    > > FE_FETCH_R                                       ~8      $7, !3, ->15
          5    >   ASSIGN                                                   !4, ~8
    9     6        IS_NOT_EQUAL                                             !3, ''
          7      > JMPZ                                                     ~10, ->14
   10     8    >   STRLEN                                           ~11     !3
          9        IS_SMALLER                                               !1, ~11
         10      > JMPZ                                                     ~12, ->14
   11    11    >   STRLEN                                           ~13     !3
         12        ASSIGN                                                   !1, ~13
   12    13        ASSIGN                                                   !2, !4
    8    14    > > JMP                                                      ->4
         15    >   FE_FREE                                                  $7
   16    16        INIT_ARRAY                                       ~16     !1, 'highest'
         17        ADD_ARRAY_ELEMENT                                ~16     !2, 'position'
         18      > RETURN                                                   ~16
   17    19*     > RETURN                                                   null

End of function getzeros

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.45 ms | 1016 KiB | 14 Q