Answer the question
In order to leave comments, you need to log in
What does this regular expression mean?
What does this regular expression mean in PHP?
"#^post/(?P\d+)$#"
This part of it is interesting:
(?P\d+)
What does the letter P mean , and in principle this fragment? And what do the brackets mean?
Answer the question
In order to leave comments, you need to log in
This is like an incomplete entry of a named subpattern. Incomplete - because there is not enough name in angle (or in apostophes) brackets:
$str = 'post/123';
if (preg_match("#^post/(?P<name>\d+)$#", $str, $arr)) {
var_dump($arr);
}
The result will be an array: Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question