3v4l.org

run code in 300+ PHP versions simultaneously
<?php $total_pages = 10; $current_page = 1; $boundaries = 1; $around = 1; $startPages = range(1, max($boundaries, 1)); $endPages = range($total_pages - max(($boundaries - 1), 0), $total_pages); $aroundLeft = range(max($current_page - $around, 1), $current_page); $aroundRight = range($current_page, min($current_page + $around, $total_pages)); $result = array_values(array_unique(array_merge($startPages, $aroundLeft, $aroundRight, $endPages))); $final = array(); for($i = 0; $i<count($result) -1;$i++) { array_push($final, $result[$i]); if($result[$i+1] - $result[$i] > 1) { array_push($final, "..."); } } array_push($final, $result[count($result) - 1]); foreach($final as $item) { echo $item . " "; } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 76
Branch analysis from position: 76
2 jumps found. (Code = 44) Position 1 = 80, Position 2 = 60
Branch analysis from position: 80
2 jumps found. (Code = 77) Position 1 = 88, Position 2 = 92
Branch analysis from position: 88
2 jumps found. (Code = 78) Position 1 = 89, Position 2 = 92
Branch analysis from position: 89
1 jumps found. (Code = 42) Position 1 = 88
Branch analysis from position: 88
Branch analysis from position: 92
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 92
Branch analysis from position: 60
2 jumps found. (Code = 43) Position 1 = 71, Position 2 = 75
Branch analysis from position: 71
2 jumps found. (Code = 44) Position 1 = 80, Position 2 = 60
Branch analysis from position: 80
Branch analysis from position: 60
Branch analysis from position: 75
filename:       /in/iuVcO
function name:  (null)
number of ops:  94
compiled vars:  !0 = $total_pages, !1 = $current_page, !2 = $boundaries, !3 = $around, !4 = $startPages, !5 = $endPages, !6 = $aroundLeft, !7 = $aroundRight, !8 = $result, !9 = $final, !10 = $i, !11 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 10
    4     1        ASSIGN                                                   !1, 1
    5     2        ASSIGN                                                   !2, 1
    6     3        ASSIGN                                                   !3, 1
    8     4        INIT_FCALL                                               'range'
          5        SEND_VAL                                                 1
          6        INIT_FCALL                                               'max'
          7        SEND_VAR                                                 !2
          8        SEND_VAL                                                 1
          9        DO_ICALL                                         $16     
         10        SEND_VAR                                                 $16
         11        DO_ICALL                                         $17     
         12        ASSIGN                                                   !4, $17
    9    13        INIT_FCALL                                               'range'
         14        INIT_FCALL                                               'max'
         15        SUB                                              ~19     !2, 1
         16        SEND_VAL                                                 ~19
         17        SEND_VAL                                                 0
         18        DO_ICALL                                         $20     
         19        SUB                                              ~21     !0, $20
         20        SEND_VAL                                                 ~21
         21        SEND_VAR                                                 !0
         22        DO_ICALL                                         $22     
         23        ASSIGN                                                   !5, $22
   11    24        INIT_FCALL                                               'range'
         25        INIT_FCALL                                               'max'
         26        SUB                                              ~24     !1, !3
         27        SEND_VAL                                                 ~24
         28        SEND_VAL                                                 1
         29        DO_ICALL                                         $25     
         30        SEND_VAR                                                 $25
         31        SEND_VAR                                                 !1
         32        DO_ICALL                                         $26     
         33        ASSIGN                                                   !6, $26
   12    34        INIT_FCALL                                               'range'
         35        SEND_VAR                                                 !1
         36        INIT_FCALL                                               'min'
         37        ADD                                              ~28     !1, !3
         38        SEND_VAL                                                 ~28
         39        SEND_VAR                                                 !0
         40        DO_ICALL                                         $29     
         41        SEND_VAR                                                 $29
         42        DO_ICALL                                         $30     
         43        ASSIGN                                                   !7, $30
   14    44        INIT_FCALL                                               'array_values'
         45        INIT_FCALL                                               'array_unique'
         46        INIT_FCALL                                               'array_merge'
         47        SEND_VAR                                                 !4
         48        SEND_VAR                                                 !6
         49        SEND_VAR                                                 !7
         50        SEND_VAR                                                 !5
         51        DO_ICALL                                         $32     
         52        SEND_VAR                                                 $32
         53        DO_ICALL                                         $33     
         54        SEND_VAR                                                 $33
         55        DO_ICALL                                         $34     
         56        ASSIGN                                                   !8, $34
   16    57        ASSIGN                                                   !9, <array>
   17    58        ASSIGN                                                   !10, 0
         59      > JMP                                                      ->76
   18    60    >   INIT_FCALL                                               'array_push'
         61        SEND_REF                                                 !9
         62        FETCH_DIM_R                                      ~38     !8, !10
         63        SEND_VAL                                                 ~38
         64        DO_ICALL                                                 
   19    65        ADD                                              ~40     !10, 1
         66        FETCH_DIM_R                                      ~41     !8, ~40
         67        FETCH_DIM_R                                      ~42     !8, !10
         68        SUB                                              ~43     ~41, ~42
         69        IS_SMALLER                                               1, ~43
         70      > JMPZ                                                     ~44, ->75
   20    71    >   INIT_FCALL                                               'array_push'
         72        SEND_REF                                                 !9
         73        SEND_VAL                                                 '...'
         74        DO_ICALL                                                 
   17    75    >   PRE_INC                                                  !10
         76    >   COUNT                                            ~47     !8
         77        SUB                                              ~48     ~47, 1
         78        IS_SMALLER                                               !10, ~48
         79      > JMPNZ                                                    ~49, ->60
   23    80    >   INIT_FCALL                                               'array_push'
         81        SEND_REF                                                 !9
         82        COUNT                                            ~50     !8
         83        SUB                                              ~51     ~50, 1
         84        FETCH_DIM_R                                      ~52     !8, ~51
         85        SEND_VAL                                                 ~52
         86        DO_ICALL                                                 
   25    87      > FE_RESET_R                                       $54     !9, ->92
         88    > > FE_FETCH_R                                               $54, !11, ->92
   26    89    >   CONCAT                                           ~55     !11, '+'
         90        ECHO                                                     ~55
   25    91      > JMP                                                      ->88
         92    >   FE_FREE                                                  $54
   30    93      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.99 ms | 1404 KiB | 27 Q