3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [0, false, null]; $flag = 0; $firstElement = $arr[0]; foreach($arr as $val){ // CHECK IF THE FIRST ELEMENT DIFFERS FROM ANY OTHER ELEMENT IN THE ARRAY if($firstElement != $val){ // FIRST MISMATCH FOUND. UPDATE FLAG VALUE AND BREAK OUT OF THE LOOP. $flag = 1; break; } } if($flag == 0){ echo 'ALL THE ELEMENTS ARE SAME'; }else{ echo 'ALL THE ELEMENTS ARE NOT SAME'; }
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
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 11
Branch analysis from position: 11
filename:       /in/jjLGf
function name:  (null)
number of ops:  18
compiled vars:  !0 = $arr, !1 = $flag, !2 = $firstElement, !3 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, 0
    5     2        FETCH_DIM_R                                      ~6      !0, 0
          3        ASSIGN                                                   !2, ~6
    7     4      > FE_RESET_R                                       $8      !0, ->11
          5    > > FE_FETCH_R                                               $8, !3, ->11
    9     6    >   IS_NOT_EQUAL                                             !2, !3
          7      > JMPZ                                                     ~9, ->10
   11     8    >   ASSIGN                                                   !1, 1
   12     9      > JMP                                                      ->11
    7    10    > > JMP                                                      ->5
         11    >   FE_FREE                                                  $8
   16    12        IS_EQUAL                                                 !1, 0
         13      > JMPZ                                                     ~11, ->16
   17    14    >   ECHO                                                     'ALL+THE+ELEMENTS+ARE+SAME'
   16    15      > JMP                                                      ->17
   19    16    >   ECHO                                                     'ALL+THE+ELEMENTS+ARE+NOT+SAME'
   20    17    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
134.82 ms | 997 KiB | 13 Q