I'm trying to understand the preg_replace_callback function. Inside my callback, I am getting the matched string twice instead of the just one time it appears in the subject string. You can go here and copy/paste this code into the tester and see that it returns two values when I would expect one.
preg_replace_callback(
'"\b(http(s)?://\S+)"',
function($match){
var_dump($match);
die();
},
'http://a'
);
The output looks like this:
array(2) { [0]=> string(8) "http://a" [1]=> string(8) "http://a" }
The documentation mentions returning an array if the subject is an array, or a string otherwise. What's happening?