I was reading the online manual of the preg_match function and wrote up a piece of code to test it. Along with it I wrote up another piece of code using preg_grep.
Here is the code:
$subject = array("Robert");
$subject2 = "Robert";
$pattern = "/./";
$result = preg_grep($pattern, $subject);
$result2 = preg_match($pattern, $subject2, $matches);
echo "<pre>";
print_r($result);
print_r($matches);
echo "</pre>";
For the preg_grep I got what I expected, an array element[0] with the value "Robert", that made sense.
For preg_match I got an unexpected result, at least to my understanding of regexp. It was an array element[0] with the value "R".
Why is that?