3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [1, 2, 3, 4, 4, 1, 2, 5, 5, 11, 11]; sort($arr); for($i = 0, $max = count($arr); $i < $max; $i++){ // is single number last element in array? if($i == count($arr)-1) $singleNum = $arr[$i]; // If adjacent elements the same, skip if($i < count($arr)-1 && $arr[$i] == $arr[$i+1]){ $i++; } else { // found single number. $singleNum = $arr[$i]; } } var_dump($singleNum);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 8
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
2 jumps found. (Code = 46) Position 1 = 18, Position 2 = 23
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 8
Branch analysis from position: 31
Branch analysis from position: 8
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 8
Branch analysis from position: 31
Branch analysis from position: 8
Branch analysis from position: 23
Branch analysis from position: 14
filename:       /in/eFs4Y
function name:  (null)
number of ops:  35
compiled vars:  !0 = $arr, !1 = $i, !2 = $max, !3 = $singleNum
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        INIT_FCALL                                               'sort'
          2        SEND_REF                                                 !0
          3        DO_ICALL                                                 
    7     4        ASSIGN                                                   !1, 0
          5        COUNT                                            ~7      !0
          6        ASSIGN                                                   !2, ~7
          7      > JMP                                                      ->29
   10     8    >   COUNT                                            ~9      !0
          9        SUB                                              ~10     ~9, 1
         10        IS_EQUAL                                                 !1, ~10
         11      > JMPZ                                                     ~11, ->14
   11    12    >   FETCH_DIM_R                                      ~12     !0, !1
         13        ASSIGN                                                   !3, ~12
   14    14    >   COUNT                                            ~14     !0
         15        SUB                                              ~15     ~14, 1
         16        IS_SMALLER                                       ~16     !1, ~15
         17      > JMPZ_EX                                          ~16     ~16, ->23
         18    >   FETCH_DIM_R                                      ~17     !0, !1
         19        ADD                                              ~18     !1, 1
         20        FETCH_DIM_R                                      ~19     !0, ~18
         21        IS_EQUAL                                         ~20     ~17, ~19
         22        BOOL                                             ~16     ~20
         23    > > JMPZ                                                     ~16, ->26
   15    24    >   PRE_INC                                                  !1
   14    25      > JMP                                                      ->28
   20    26    >   FETCH_DIM_R                                      ~22     !0, !1
         27        ASSIGN                                                   !3, ~22
    7    28    >   PRE_INC                                                  !1
         29    >   IS_SMALLER                                               !1, !2
         30      > JMPNZ                                                    ~25, ->8
   23    31    >   INIT_FCALL                                               'var_dump'
         32        SEND_VAR                                                 !3
         33        DO_ICALL                                                 
         34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.04 ms | 1006 KiB | 15 Q