PCREs have to be enclosed in delimiters.
You have to either escape the inner \
or use another delimiter:
~/zeta/.{4}/(.{2})/$~'
Otherwise, PHP thinks the expression is /zeta/
only and .
is not a valid modifier.
preg_match
does not return an array. You can inspect the contents of $monthnum
with var_dump
and access the information you want.
You could have solved your problem by simply reading the documentation:
If matches
is provided, then it is filled with the results of search. $matches[0]
will contain the text that matched the full pattern, $matches[1]
will have the text that matched the first captured parenthesized subpattern, and so on.
and
preg_match() returns the number of times pattern matches. That will be either 0 times (no match) or 1 time because preg_match() will stop searching after the first match.