3v4l.org

run code in 500+ PHP versions simultaneously
<?php $a = array(99, 95, 101, 102, 103, 98, 97, 110); $number = 100; $diff = []; foreach($a as $ele){ $diff[abs($number - $ele)][] = $ele; } ksort($diff,SORT_NUMERIC); print_r($diff);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/QPX1o
function name:  (null)
number of ops:  22
compiled vars:  !0 = $a, !1 = $number, !2 = $diff, !3 = $ele
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    5     1        ASSIGN                                                       !1, 100
    6     2        ASSIGN                                                       !2, <array>
    8     3      > FE_RESET_R                                           $7      !0, ->13
          4    > > FE_FETCH_R                                                   $7, !3, ->13
    9     5    >   INIT_FCALL                                                   'abs'
          6        SUB                                                  ~8      !1, !3
          7        SEND_VAL                                                     ~8
          8        DO_ICALL                                             $9      
          9        FETCH_DIM_W                                          $10     !2, $9
         10        ASSIGN_DIM                                                   $10
         11        OP_DATA                                                      !3
    8    12      > JMP                                                          ->4
         13    >   FE_FREE                                                      $7
   12    14        INIT_FCALL                                                   'ksort'
         15        SEND_REF                                                     !2
         16        SEND_VAL                                                     1
         17        DO_ICALL                                                     
   13    18        INIT_FCALL                                                   'print_r'
         19        SEND_VAR                                                     !2
         20        DO_ICALL                                                     
         21      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
178.69 ms | 2232 KiB | 16 Q