The returned matches array contains as the first element the entire string matched, followed by the captured groups.
I can’t locate an option on php.net to just return the captured groups?
Is there one?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, it is standard for
0to contain the entire matched string.If it were of a concern, you could always
unset($matches[0])(which won’t affect the keys) orarray_slice($matches, 1).