3v4l.org

run code in 300+ PHP versions simultaneously
<?php $ids = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110]; $users = [1,2,3,4,5]; // Temporary copy of users $user_ids = []; foreach( $ids as $id ){ // If our copy is empty, reload it if(!$user_ids){ $user_ids = $users; } // Use array_shift() to grab and remove from the front echo sprintf('%1$d - %2$d', $id, array_shift($user_ids)), PHP_EOL; } echo PHP_EOL; foreach( $ids as $idx => $id ){ echo sprintf('%1$d - %2$d', $id, ($idx % 5) + 1 ), PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 19
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 19
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 8
Branch analysis from position: 19
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 34
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 34
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
Branch analysis from position: 19
filename:       /in/LuRQj
function name:  (null)
number of ops:  36
compiled vars:  !0 = $ids, !1 = $users, !2 = $user_ids, !3 = $id, !4 = $idx
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    7     2        ASSIGN                                                   !2, <array>
    8     3      > FE_RESET_R                                       $8      !0, ->19
          4    > > FE_FETCH_R                                               $8, !3, ->19
   11     5    >   BOOL_NOT                                         ~9      !2
          6      > JMPZ                                                     ~9, ->8
   12     7    >   ASSIGN                                                   !2, !1
   16     8    >   INIT_FCALL                                               'sprintf'
          9        SEND_VAL                                                 '%251%24d+-+%252%24d'
         10        SEND_VAR                                                 !3
         11        INIT_FCALL                                               'array_shift'
         12        SEND_REF                                                 !2
         13        DO_ICALL                                         $11     
         14        SEND_VAR                                                 $11
         15        DO_ICALL                                         $12     
         16        ECHO                                                     $12
         17        ECHO                                                     '%0A'
    8    18      > JMP                                                      ->4
         19    >   FE_FREE                                                  $8
   19    20        ECHO                                                     '%0A'
   21    21      > FE_RESET_R                                       $13     !0, ->34
         22    > > FE_FETCH_R                                       ~14     $13, !3, ->34
         23    >   ASSIGN                                                   !4, ~14
   22    24        INIT_FCALL                                               'sprintf'
         25        SEND_VAL                                                 '%251%24d+-+%252%24d'
         26        SEND_VAR                                                 !3
         27        MOD                                              ~16     !4, 5
         28        ADD                                              ~17     ~16, 1
         29        SEND_VAL                                                 ~17
         30        DO_ICALL                                         $18     
         31        ECHO                                                     $18
         32        ECHO                                                     '%0A'
   21    33      > JMP                                                      ->22
         34    >   FE_FREE                                                  $13
   23    35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.91 ms | 1073 KiB | 15 Q