3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = [ "Jan 12 02:08:23 hello", "Dec 23 21:37:56 hello", //"Jan 12 02:08:23 hello", //"Jan 16 17:34:33 hello", "Feb 4 12:21:09 hello", "Mar 19 17:07:26 hello", "Apr 1 00:00:03 hello", "Nov 10 11:00:03 hello", "Apr 12 23:07:39 hello", "May 21 04:09:34 hello", "Jun 7 23:34:56 hello", "Sep 29 07:36:03 hello", "Jul 1 14:45:34 hello", "Aug 13 11:37:23 hello", "Sep 29 07:36:03 hello", "Oct 30 09:01:00 hello", "Nov 10 11:00:03 hello", "Dec 25 21:47:51 hello" ]; var_export( preg_replace_callback( '/^([a-z]{3}) +\d+/i', function($m) { static $lastMonthInt = 0; static $year = null; $year ??= date('Y', strtotime('-1 year')); $currentMonthInt = date('n', strtotime($m[1])); if ($currentMonthInt < $lastMonthInt) { ++$year; } $lastMonthInt = $currentMonthInt; return "$year " . date('m d', strtotime($m[0])); }, $arr ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JBvtv
function name:  (null)
number of ops:  11
compiled vars:  !0 = $arr
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   24     1        INIT_FCALL                                                   'var_export'
   25     2        INIT_FCALL                                                   'preg_replace_callback'
   26     3        SEND_VAL                                                     '%2F%5E%28%5Ba-z%5D%7B3%7D%29+%2B%5Cd%2B%2Fi'
   27     4        DECLARE_LAMBDA_FUNCTION                              ~2      [0]
   37     5        SEND_VAL                                                     ~2
   38     6        SEND_VAR                                                     !0
   25     7        DO_ICALL                                             $3      
   38     8        SEND_VAR                                                     $3
   24     9        DO_ICALL                                                     
   40    10      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 26
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/JBvtv
function name:  {closure:/in/JBvtv:27}
number of ops:  40
compiled vars:  !0 = $m, !1 = $lastMonthInt, !2 = $year, !3 = $currentMonthInt
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   27     0  E >   RECV                                                 !0      
   28     1        BIND_STATIC                                                  !1
   29     2        BIND_STATIC                                                  !2
   30     3        COALESCE                                             ~4      !2
          4        INIT_FCALL                                                   'date'
          5        SEND_VAL                                                     'Y'
          6        INIT_FCALL                                                   'strtotime'
          7        SEND_VAL                                                     '-1+year'
          8        DO_ICALL                                             $5      
          9        SEND_VAR                                                     $5
         10        DO_ICALL                                             $6      
         11        ASSIGN                                               ~7      !2, $6
         12        QM_ASSIGN                                            ~4      ~7
         13        FREE                                                         ~4
   31    14        INIT_FCALL                                                   'date'
         15        SEND_VAL                                                     'n'
         16        INIT_FCALL                                                   'strtotime'
         17        FETCH_DIM_R                                          ~8      !0, 1
         18        SEND_VAL                                                     ~8
         19        DO_ICALL                                             $9      
         20        SEND_VAR                                                     $9
         21        DO_ICALL                                             $10     
         22        ASSIGN                                                       !3, $10
   32    23        IS_SMALLER                                                   !3, !1
         24      > JMPZ                                                         ~12, ->26
   33    25    >   PRE_INC                                                      !2
   35    26    >   ASSIGN                                                       !1, !3
   36    27        NOP                                                          
         28        FAST_CONCAT                                          ~15     !2, '+'
         29        INIT_FCALL                                                   'date'
         30        SEND_VAL                                                     'm+d'
         31        INIT_FCALL                                                   'strtotime'
         32        FETCH_DIM_R                                          ~16     !0, 0
         33        SEND_VAL                                                     ~16
         34        DO_ICALL                                             $17     
         35        SEND_VAR                                                     $17
         36        DO_ICALL                                             $18     
         37        CONCAT                                               ~19     ~15, $18
         38      > RETURN                                                       ~19
   37    39*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
194.56 ms | 1806 KiB | 17 Q