3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ [ 'name' => 'LILI', 'actual_start' => '2021-11-10T18:34:00+00:00', 'actual_end' => '2021-11-10T21:32:00+00:00', ], [ 'name' => 'MILI', 'actual_start' => '2021-11-18T17:33:00+00:00', 'actual_end' => '2022-03-18T19:36:00+00:00', ], [ 'name' => 'VANILI', 'actual_start' => '2021-11-18T17:33:00+00:00', 'actual_end' => '2022-03-18T17:36:00+00:00', ], [ 'name' => 'MANILA', 'actual_start' => '2021-11-18T11:33:00+00:00', 'actual_end' => '2022-03-18T19:36:00+00:00', ] ]; $size = 3; $maxes = array_fill(0, $size, 0); $names = []; foreach ($array as $row) { $diff = strtotime($row['actual_end']) - strtotime($row['actual_start']); foreach ($maxes as $i => $max) { if ($diff > $max) { array_splice($maxes, $i, 0, $diff); array_splice($names, $i, 0, $row['name']); unset($maxes[$size], $names[$size]); break; } } } echo implode(' ', $names);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 45
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 45
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 43
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 43
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 42
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 43
Branch analysis from position: 43
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
filename:       /in/bVd1H
function name:  (null)
number of ops:  49
compiled vars:  !0 = $array, !1 = $size, !2 = $maxes, !3 = $names, !4 = $row, !5 = $diff, !6 = $max, !7 = $i
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   26     1        ASSIGN                                                       !1, 3
   27     2        INIT_FCALL                                                   'array_fill'
          3        SEND_VAL                                                     0
          4        SEND_VAR                                                     !1
          5        SEND_VAL                                                     0
          6        DO_ICALL                                             $10     
          7        ASSIGN                                                       !2, $10
   28     8        ASSIGN                                                       !3, <array>
   30     9      > FE_RESET_R                                           $13     !0, ->45
         10    > > FE_FETCH_R                                                   $13, !4, ->45
   31    11    >   INIT_FCALL                                                   'strtotime'
         12        FETCH_DIM_R                                          ~14     !4, 'actual_end'
         13        SEND_VAL                                                     ~14
         14        DO_ICALL                                             $15     
         15        INIT_FCALL                                                   'strtotime'
         16        FETCH_DIM_R                                          ~16     !4, 'actual_start'
         17        SEND_VAL                                                     ~16
         18        DO_ICALL                                             $17     
         19        SUB                                                  ~18     $15, $17
         20        ASSIGN                                                       !5, ~18
   32    21      > FE_RESET_R                                           $20     !2, ->43
         22    > > FE_FETCH_R                                           ~21     $20, !6, ->43
         23    >   ASSIGN                                                       !7, ~21
   33    24        IS_SMALLER                                                   !6, !5
         25      > JMPZ                                                         ~23, ->42
   34    26    >   INIT_FCALL                                                   'array_splice'
         27        SEND_REF                                                     !2
         28        SEND_VAR                                                     !7
         29        SEND_VAL                                                     0
         30        SEND_VAR                                                     !5
         31        DO_ICALL                                                     
   35    32        INIT_FCALL                                                   'array_splice'
         33        SEND_REF                                                     !3
         34        SEND_VAR                                                     !7
         35        SEND_VAL                                                     0
         36        FETCH_DIM_R                                          ~25     !4, 'name'
         37        SEND_VAL                                                     ~25
         38        DO_ICALL                                                     
   36    39        UNSET_DIM                                                    !2, !1
         40        UNSET_DIM                                                    !3, !1
   37    41      > JMP                                                          ->43
   32    42    > > JMP                                                          ->22
         43    >   FE_FREE                                                      $20
   30    44      > JMP                                                          ->10
         45    >   FE_FREE                                                      $13
   42    46        FRAMELESS_ICALL_2                implode             ~27     '+', !3
         47        ECHO                                                         ~27
         48      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
151.19 ms | 1768 KiB | 17 Q