If you execute the code as it is, you get:
April1,2003
This is because you are delimiting the variable $1
to separate it from what would be $11
. Here's more on that.
If you change it, you get:
,2003
...because backreference $11
doesn't exist.
Why is $3
declared before the ending string symbol? Because it's part of the preg_replace
backreference. If you move it outside of the replacement string, you'll see it crash and burn.
Footnote: why you're replacing this with <variable>1,<variable>
seems really odd. That 1
is static - in that it never changes. I'd be more inclined to think you'd want a replacement like ${1}${2},$3
which would return April15,2003
.