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);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'action' => 'Created', 'timestamp' => '2023-10-30 20:51:57.284602', ), 1 => array ( 'action' => 'Updated', 'timestamp' => '2023-10-30 20:51:57.284603', ), 2 => array ( 'action' => 'Started', 'timestamp' => '2023-10-30 20:51:57.284604', ), 3 => array ( 'action' => 'Max bid placed', 'timestamp' => '2023-10-30 20:51:57.284607', ), 4 => array ( 'action' => 'Bid placed', 'timestamp' => '2023-10-30 20:51:57.284605', ), 5 => array ( 'action' => 'Bid placed', 'timestamp' => '2023-10-30 20:51:57.284606', ), 6 => array ( 'action' => 'Bid placed', 'timestamp' => '2023-10-30 20:51:57.284608', ), 7 => array ( 'action' => 'Had a nap', 'timestamp' => '2023-10-30 20:51:57.284609', ), 8 => array ( 'action' => 'Max bid placed', 'timestamp' => '2023-10-30 20:51:57.284612', ), 9 => array ( 'action' => 'Bid placed', 'timestamp' => '2023-10-30 20:51:57.284611', ), 10 => array ( 'action' => 'Ended', 'timestamp' => '2023-10-30 20:51:57.284613', ), )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
62.85 ms | 409 KiB | 5 Q