preg_matchtakes an argument $matchesas a reference. All the examples that I saw do not initialize it before they are passed as an argument. Like this:
preg_match($somePattern, $someSubject, $matches);
print_r($matches);
Isn't that error prone? What if it $matchesalready contains a value? I think it should be initialized with an empty array before passing it as an argument. Like this:
$matches = array();
preg_match($somePattern, $someSubject, $matches);
print_r($matches);
Am I just paranoid?
source
share