3v4l.org

run code in 300+ PHP versions simultaneously
<?php $people = [ [1801, 1887], [1943, 1943], [1949, 2001], [1751, 1803], [1881, 1887], [1956, 1983], [1954, 1983], [1801, 1883], [1956, null], [1944, 1983], [1897, 2015], [1965, 1997], [1941, 1982], [1984, null], ]; $populationPerYear = array_reduce( $people, static function($carry, $current) { [$from, $to] = $current; for($i = $from; $i <= $to; $i++) { if (!isset($carry[$i])) { $carry[$i] = 1; } else { $carry[$i]++; } } return $carry; }, [] ); ksort($populationPerYear); $peak = max($populationPerYear); $peakYears = array_filter( $populationPerYear, static function($population) use ($peak) { return $population === $peak; } ); var_dump($peak, $peakYears);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PB2Bj
function name:  (null)
number of ops:  27
compiled vars:  !0 = $people, !1 = $populationPerYear, !2 = $peak, !3 = $peakYears
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   20     1        INIT_FCALL                                               'array_reduce'
   21     2        SEND_VAR                                                 !0
   22     3        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
   32     4        SEND_VAL                                                 ~5
   33     5        SEND_VAL                                                 <array>
   20     6        DO_ICALL                                         $6      
          7        ASSIGN                                                   !1, $6
   35     8        INIT_FCALL                                               'ksort'
          9        SEND_REF                                                 !1
         10        DO_ICALL                                                 
   36    11        INIT_FCALL                                               'max'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $9      
         14        ASSIGN                                                   !2, $9
   38    15        INIT_FCALL                                               'array_filter'
   39    16        SEND_VAR                                                 !1
   40    17        DECLARE_LAMBDA_FUNCTION                          ~11     [1]
         18        BIND_LEXICAL                                             ~11, !2
   42    19        SEND_VAL                                                 ~11
   38    20        DO_ICALL                                         $12     
         21        ASSIGN                                                   !3, $12
   45    22        INIT_FCALL                                               'var_dump'
         23        SEND_VAR                                                 !2
         24        SEND_VAR                                                 !3
         25        DO_ICALL                                                 
         26      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 10
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 10
Branch analysis from position: 21
Branch analysis from position: 10
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 10
Branch analysis from position: 21
Branch analysis from position: 10
filename:       /in/PB2Bj
function name:  {closure}
number of ops:  23
compiled vars:  !0 = $carry, !1 = $current, !2 = $from, !3 = $to, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   23     2        QM_ASSIGN                                        ~5      !1
          3        FETCH_LIST_R                                     $6      ~5, 0
          4        ASSIGN                                                   !2, $6
          5        FETCH_LIST_R                                     $8      ~5, 1
          6        ASSIGN                                                   !3, $8
          7        FREE                                                     ~5
   24     8        ASSIGN                                                   !4, !2
          9      > JMP                                                      ->19
   25    10    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~11     !0, !4
         11        BOOL_NOT                                         ~12     ~11
         12      > JMPZ                                                     ~12, ->16
   26    13    >   ASSIGN_DIM                                               !0, !4
         14        OP_DATA                                                  1
   25    15      > JMP                                                      ->18
   28    16    >   FETCH_DIM_RW                                     $14     !0, !4
         17        PRE_INC                                                  $14
   24    18    >   PRE_INC                                                  !4
         19    >   IS_SMALLER_OR_EQUAL                                      !4, !3
         20      > JMPNZ                                                    ~17, ->10
   31    21    > > RETURN                                                   !0
   32    22*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PB2Bj
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $population, !1 = $peak
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   41     2        IS_IDENTICAL                                     ~2      !0, !1
          3      > RETURN                                                   ~2
   42     4*     > RETURN                                                   null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.01 ms | 1435 KiB | 18 Q