3v4l.org

run code in 300+ PHP versions simultaneously
<?php $date = '2023-09-04'; $times = ['1055', '10:55']; foreach ($times as $time) { $time = preg_replace('/\d{2}\K:?/', ':', $time, 1); // fix your inconsistent time formatting echo (new DateTime("$date $time:00.000"))->format('z') . "\n"; // set the datetime object all at once }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 24
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 24
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/S8ZZO
function name:  (null)
number of ops:  26
compiled vars:  !0 = $date, !1 = $times, !2 = $time
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '2023-09-04'
    4     1        ASSIGN                                                   !1, <array>
    5     2      > FE_RESET_R                                       $5      !1, ->24
          3    > > FE_FETCH_R                                               $5, !2, ->24
    6     4    >   INIT_FCALL                                               'preg_replace'
          5        SEND_VAL                                                 '%2F%5Cd%7B2%7D%5CK%3A%3F%2F'
          6        SEND_VAL                                                 '%3A'
          7        SEND_VAR                                                 !2
          8        SEND_VAL                                                 1
          9        DO_ICALL                                         $6      
         10        ASSIGN                                                   !2, $6
    7    11        NEW                                              $8      'DateTime'
         12        ROPE_INIT                                     4  ~10     !0
         13        ROPE_ADD                                      1  ~10     ~10, '+'
         14        ROPE_ADD                                      2  ~10     ~10, !2
         15        ROPE_END                                      3  ~9      ~10, '%3A00.000'
         16        SEND_VAL_EX                                              ~9
         17        DO_FCALL                                      0          
         18        INIT_METHOD_CALL                                         $8, 'format'
         19        SEND_VAL_EX                                              'z'
         20        DO_FCALL                                      0  $13     
         21        CONCAT                                           ~14     $13, '%0A'
         22        ECHO                                                     ~14
    5    23      > JMP                                                      ->3
         24    >   FE_FREE                                                  $5
    8    25      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.55 ms | 1010 KiB | 14 Q