3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Keys are ISO-8601 numeric representation * of the days of the week */ $days = [ 1 => 0b0000001, // 1 2 => 0b0000010, // 2 3 => 0b0000100, // 4 4 => 0b0001000, // 8 5 => 0b0010000, // 16 6 => 0b0100000, // 32 7 => 0b1000000, // 64 ]; $mondayToFriday = 31; // 1 + 2 + 4 + 8 + 16 foreach ($days as $n => $v) { /** * Get the day's name using strftime (has locale capability) * strtotime("Sunday +n days") would work with ISO-8601 day * numbers or PHP's date("w") (0 - 6 / Sunday - Saturday) */ $day = strftime("%A", strtotime("Sunday +{$n} days")); echo "{$day}: " . (($v & $mondayToFriday) ? "Y" : "N") . PHP_EOL; } echo PHP_EOL; /** * The order of these is important */ $input["days"] = [ "Monday" => 0, "Tuesday" => 1, "Wednesday" => 0, "Thursday" => 0, "Friday" => 0, "Saturday" => 0, "Sunday" => 0, ]; $dec = bindec(strrev(implode("", $input["days"]))); echo "\$dec: {$dec}" . PHP_EOL;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 27
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 27
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/R6u1v
function name:  (null)
number of ops:  48
compiled vars:  !0 = $days, !1 = $mondayToFriday, !2 = $v, !3 = $n, !4 = $day, !5 = $input, !6 = $dec
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN                                                   !0, <array>
   19     1        ASSIGN                                                   !1, 31
   21     2      > FE_RESET_R                                       $9      !0, ->27
          3    > > FE_FETCH_R                                       ~10     $9, !2, ->27
          4    >   ASSIGN                                                   !3, ~10
   28     5        INIT_FCALL                                               'strftime'
          6        SEND_VAL                                                 '%25A'
          7        INIT_FCALL                                               'strtotime'
          8        ROPE_INIT                                     3  ~13     'Sunday+%2B'
          9        ROPE_ADD                                      1  ~13     ~13, !3
         10        ROPE_END                                      2  ~12     ~13, '+days'
         11        SEND_VAL                                                 ~12
         12        DO_ICALL                                         $15     
         13        SEND_VAR                                                 $15
         14        DO_ICALL                                         $16     
         15        ASSIGN                                                   !4, $16
   31    16        NOP                                                      
         17        FAST_CONCAT                                      ~18     !4, '%3A+'
         18        BW_AND                                           ~19     !2, !1
         19      > JMPZ                                                     ~19, ->22
         20    >   QM_ASSIGN                                        ~20     'Y'
         21      > JMP                                                      ->23
         22    >   QM_ASSIGN                                        ~20     'N'
         23    >   CONCAT                                           ~21     ~18, ~20
         24        CONCAT                                           ~22     ~21, '%0A'
         25        ECHO                                                     ~22
   21    26      > JMP                                                      ->3
         27    >   FE_FREE                                                  $9
   35    28        ECHO                                                     '%0A'
   40    29        ASSIGN_DIM                                               !5, 'days'
   41    30        OP_DATA                                                  <array>
   51    31        INIT_FCALL                                               'bindec'
         32        INIT_FCALL                                               'strrev'
         33        INIT_FCALL                                               'implode'
         34        SEND_VAL                                                 ''
         35        FETCH_DIM_R                                      ~24     !5, 'days'
         36        SEND_VAL                                                 ~24
         37        DO_ICALL                                         $25     
         38        SEND_VAR                                                 $25
         39        DO_ICALL                                         $26     
         40        SEND_VAR                                                 $26
         41        DO_ICALL                                         $27     
         42        ASSIGN                                                   !6, $27
   53    43        NOP                                                      
         44        FAST_CONCAT                                      ~29     '%24dec%3A+', !6
         45        CONCAT                                           ~30     ~29, '%0A'
         46        ECHO                                                     ~30
   54    47      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.22 ms | 1405 KiB | 23 Q