I have the following code:
$f = 'IMG_1474.PNG';
preg_replace('/(.*)([.][^.]+$)/', '$1' . time() . '$2', $f)
which should split the IMG_1474
and .PNG
and add the epoch in between. The first capture group appears to be empty though.
If preg_match
is used I can see the first capture group is not empty (so regex performs the same in PHP as on regex101).
preg_match('/(.*)([.][^.]+$)/', $f, $match);
print_r($match);
Functional demo: https://3v4l.org/VgDWJ (the 604147502
is the time()
result)
My presumption is that something is happening with the concatenation on the replace bit.