3v4l.org

run code in 300+ PHP versions simultaneously
<?php $products = [451, 455, 453]; $mod = count($products); $days = null; $weekdays = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]; $flipped = array_flip($weekdays); $callback = function( $e ) use( $mod ) { return ($e % $mod); }; $days = array_map( $callback, array_keys( $weekdays ) ); // listing each weekday's product ID foreach ($flipped as $wday => $dex) { echo "$wday, "; echo $products[ $days[$dex] ], "\n"; } // get current product ID: $now = time(); $today = date("l",$now); $dex = $flipped[ $today ]; echo "\nToday is $today and the current product ID is ", $products[ $days[ $dex ] ];
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 31
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 31
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/rb7bD
function name:  (null)
number of ops:  50
compiled vars:  !0 = $products, !1 = $mod, !2 = $days, !3 = $weekdays, !4 = $flipped, !5 = $callback, !6 = $dex, !7 = $wday, !8 = $now, !9 = $today
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        COUNT                                            ~11     !0
          2        ASSIGN                                                   !1, ~11
    6     3        ASSIGN                                                   !2, null
    8     4        ASSIGN                                                   !3, <array>
    9     5        INIT_FCALL                                               'array_flip'
          6        SEND_VAR                                                 !3
          7        DO_ICALL                                         $15     
          8        ASSIGN                                                   !4, $15
   12     9        DECLARE_LAMBDA_FUNCTION                          ~17     [0]
         10        BIND_LEXICAL                                             ~17, !1
         11        ASSIGN                                                   !5, ~17
   16    12        INIT_FCALL                                               'array_map'
         13        SEND_VAR                                                 !5
         14        INIT_FCALL                                               'array_keys'
         15        SEND_VAR                                                 !3
         16        DO_ICALL                                         $19     
         17        SEND_VAR                                                 $19
         18        DO_ICALL                                         $20     
         19        ASSIGN                                                   !2, $20
   19    20      > FE_RESET_R                                       $22     !4, ->31
         21    > > FE_FETCH_R                                       ~23     $22, !6, ->31
         22    >   ASSIGN                                                   !7, ~23
   20    23        NOP                                                      
         24        FAST_CONCAT                                      ~25     !7, '%2C+'
         25        ECHO                                                     ~25
   21    26        FETCH_DIM_R                                      ~26     !2, !6
         27        FETCH_DIM_R                                      ~27     !0, ~26
         28        ECHO                                                     ~27
         29        ECHO                                                     '%0A'
   19    30      > JMP                                                      ->21
         31    >   FE_FREE                                                  $22
   25    32        INIT_FCALL                                               'time'
         33        DO_ICALL                                         $28     
         34        ASSIGN                                                   !8, $28
   26    35        INIT_FCALL                                               'date'
         36        SEND_VAL                                                 'l'
         37        SEND_VAR                                                 !8
         38        DO_ICALL                                         $30     
         39        ASSIGN                                                   !9, $30
   27    40        FETCH_DIM_R                                      ~32     !4, !9
         41        ASSIGN                                                   !6, ~32
   28    42        ROPE_INIT                                     3  ~35     '%0AToday+is+'
         43        ROPE_ADD                                      1  ~35     ~35, !9
         44        ROPE_END                                      2  ~34     ~35, '+and+the+current+product+ID+is+'
         45        ECHO                                                     ~34
         46        FETCH_DIM_R                                      ~37     !2, !6
         47        FETCH_DIM_R                                      ~38     !0, ~37
         48        ECHO                                                     ~38
         49      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rb7bD
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $e, !1 = $mod
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   13     2        MOD                                              ~2      !0, !1
          3      > RETURN                                                   ~2
   14     4*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.14 ms | 1009 KiB | 18 Q