preg_match() returning xml type tags....
Moderator: General Moderators
preg_match() returning xml type tags....
I just came across this this evening and it seemed very odd to me.
I'm using a preg_match() to find a value within my string...simple enough. But when I echo out my $matches[1] key (or even print_r() the entire array for that matter) it's adding on '</key><string>my matched string is in here</string>'
the xml type tags are what it's adding (</key>, <string>, and </string>).
has anyone ever seen this? or more importantly, does anyone know a way to avoid this?
I'm using a preg_match() to find a value within my string...simple enough. But when I echo out my $matches[1] key (or even print_r() the entire array for that matter) it's adding on '</key><string>my matched string is in here</string>'
the xml type tags are what it's adding (</key>, <string>, and </string>).
has anyone ever seen this? or more importantly, does anyone know a way to avoid this?
Code: Select all
preg_match('/the-link-url(.*?)\s+/i',$string,$matches);this is a sample (I've changed the domain, but that's it)
Code: Select all
$string = "&&2bf4d *&36424 pasthro the-link-urlhttp://ap.somedomain.com?ar=344cEFG42&al=ERRc34433 &&2cf5d *&3srr2f4";- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Works fine for me. 
Code: Select all
[feyd@home]>php -r "$string = '&&2bf4d *&36424 pasthro the-link-urlhttp://ap.somedomain.com?ar=344cEFG42&al=ERRc34433 &&2cf5d *&3srr2f4'; preg_match('/the-link-url(.*?)\s+/i',$string,$matches); var_dump($matches);"
array(2) {
[0]=>
string(63) "the-link-urlhttp://ap.somedomain.com?ar=344cEFG42&al=ERRc34433 "
[1]=>
string(50) "http://ap.somedomain.com?ar=344cEFG42&al=ERRc34433"
}
[feyd@home]>php -v
PHP 5.1.5 (cli) (built: Aug 15 2006 23:54:56)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
with Xdebug v2.0.0beta6, Copyright (c) 2002, 2003, 2004, 2005, 2006, by Derick Rethans