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);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 3, Position 2 = 23
Branch analysis from position: 3
2 jumps found. (Code = 126) Position 1 = 4, Position 2 = 23
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 22
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 22
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/TUPEn
function name:  (null)
number of ops:  28
compiled vars:  !0 = $array, !1 = $newStart, !2 = $entry, !3 = $position
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   17     1        ASSIGN                                                   !1, 'thursday'
   18     2      > FE_RESET_RW                                      $6      !0, ->23
          3    > > FE_FETCH_RW                                              $6, !2, ->23
   19     4    >   INIT_FCALL                                               'array_search'
   20     5        SEND_VAR                                                 !1
   21     6        INIT_FCALL                                               'array_keys'
          7        FETCH_DIM_R                                      ~7      !2, 'schedules'
          8        SEND_VAL                                                 ~7
          9        DO_ICALL                                         $8      
         10        SEND_VAR                                                 $8
   19    11        DO_ICALL                                         $9      
         12        ASSIGN                                                   !3, $9
   23    13      > JMPZ                                                     !3, ->22
   24    14    >   INIT_FCALL                                               'array_splice'
   25    15        FETCH_DIM_W                                      $12     !2, 'schedules'
         16        SEND_REF                                                 $12
   26    17        SEND_VAL                                                 0
   27    18        SEND_VAR                                                 !3
   24    19        DO_ICALL                                         $13     
         20        ASSIGN_DIM_OP                +=               1          !2, 'schedules'
   27    21        OP_DATA                                                  $13
   18    22    > > JMP                                                      ->3
         23    >   FE_FREE                                                  $6
   31    24        INIT_FCALL                                               'var_export'
         25        SEND_VAR                                                 !0
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.86 ms | 1002 KiB | 17 Q