3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [ 'schedules' => [ 'monday' => 1, 'tuesday' => 1, 'wednesday' => 1, 'thursday' => 1, 'friday' => 1, 'saturday' => 0, 'sunday' => 1, ] ] ]; $newStart = 'thursday'; foreach ($array as &$entry) { $position = array_search( $newStart, array_keys($entry['schedules']) ); if ($position) { $entry['schedules'] += array_splice( $entry['schedules'], 0, $position ); } } var_export($array);

preferences:
25.58 ms | 407 KiB | 5 Q