preg_replace_callback and brackets
| From: | Joshua Moore-Oliva | Date: | Sun, 30 Mar 2003 03:30:42 +0000 |
| Subject: | preg_replace_callback and brackets | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-141617@lists.php.net to get a copy of this message | ||
I'm kind of confused right now... when I call preg_replace_callback with a
regular expression with brackets, sometimes I get an array back with multiple
elements like
array(3) {
[0]=>
string(19) "http://www.aol.com
"
[1]=>
string(0) ""
[2]=>
string(19) "http://www.aol.com
"
}
and I have no idea why... Why does the middle one have nothing in it? the
regular expression was
$dumb_body = preg_replace_callback ( '/'
//Case spaceURLspace
. '([\s]http:\/\/[^\s]+[\s])'
. '|'
//Case URLspace
. '(^http:\/\/[^\s]+[\s])'
. '|'
//Case spaceURL
. '([\s]http:\/\/[^\s]+$)'
. '|'
//Case URL
. '(^http:\/\/[^\s]+$)'
. '/i'
, array( &$this, "storeUrlCallback" ),
$dumb_body );
I am very confused at the point of the array in this function period... can
anyone help?
Josh.