3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['action' => 'Created', 'timestamp' => '2023-10-30 20:51:57.284602'], ['action' => 'Updated', 'timestamp' => '2023-10-30 20:51:57.284603'], ['action' => 'Started', 'timestamp' => '2023-10-30 20:51:57.284604'], ['action' => 'Bid placed', 'timestamp' => '2023-10-30 20:51:57.284605'], ['action' => 'Bid placed', 'timestamp' => '2023-10-30 20:51:57.284606'], ['action' => 'Max bid placed', 'timestamp' => '2023-10-30 20:51:57.284607'], ['action' => 'Bid placed', 'timestamp' => '2023-10-30 20:51:57.284608'], ['action' => 'Had a nap', 'timestamp' => '2023-10-30 20:51:57.284609'], //['action' => 'Max bid placed', 'timestamp' => '2023-10-30 20:51:57.284610'], ['action' => 'Bid placed', 'timestamp' => '2023-10-30 20:51:57.284611'], ['action' => 'Max bid placed', 'timestamp' => '2023-10-30 20:51:57.284612'], ['action' => 'Ended', 'timestamp' => '2023-10-30 20:51:57.284613'], ]; $start = null; foreach ($array as $i => $row) { if ($row['action'] === 'Bid placed') { $start ??= $i; // only store the first $i in the group continue; } if ($start !== null && $row['action'] === 'Max bid placed') { array_splice($array, $start, 0, array_splice($array, $i, 1)); // prune and reinsert row } $start = null; } var_export($array);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 32
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 32
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 13
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 13
2 jumps found. (Code = 46) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 30
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 30
Branch analysis from position: 18
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/WvlIp
function name:  (null)
number of ops:  37
compiled vars:  !0 = $array, !1 = $start, !2 = $row, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   18     1        ASSIGN                                                   !1, null
   19     2      > FE_RESET_R                                       $6      !0, ->32
          3    > > FE_FETCH_R                                       ~7      $6, !2, ->32
          4    >   ASSIGN                                                   !3, ~7
   20     5        FETCH_DIM_R                                      ~9      !2, 'action'
          6        IS_IDENTICAL                                             ~9, 'Bid+placed'
          7      > JMPZ                                                     ~10, ->13
   21     8    >   COALESCE                                         ~11     !1
          9        ASSIGN                                           ~12     !1, !3
         10        QM_ASSIGN                                        ~11     ~12
         11        FREE                                                     ~11
   22    12      > JMP                                                      ->3
   24    13    >   TYPE_CHECK                                  1020  ~13     !1
         14      > JMPZ_EX                                          ~13     ~13, ->18
         15    >   FETCH_DIM_R                                      ~14     !2, 'action'
         16        IS_IDENTICAL                                     ~15     ~14, 'Max+bid+placed'
         17        BOOL                                             ~13     ~15
         18    > > JMPZ                                                     ~13, ->30
   25    19    >   INIT_FCALL                                               'array_splice'
         20        SEND_REF                                                 !0
         21        SEND_VAR                                                 !1
         22        SEND_VAL                                                 0
         23        INIT_FCALL                                               'array_splice'
         24        SEND_REF                                                 !0
         25        SEND_VAR                                                 !3
         26        SEND_VAL                                                 1
         27        DO_ICALL                                         $16     
         28        SEND_VAR                                                 $16
         29        DO_ICALL                                                 
   27    30    >   ASSIGN                                                   !1, null
   19    31      > JMP                                                      ->3
         32    >   FE_FREE                                                  $6
   29    33        INIT_FCALL                                               'var_export'
         34        SEND_VAR                                                 !0
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
134.43 ms | 1006 KiB | 15 Q