wuwei101 Posted July 5, 2006 Share Posted July 5, 2006 hello,Here's the code I have:[code]if (! PEAR::isError($req->sendRequest())) { if (preg_match('/edg176\/(\d+)/', $req->getResponseBody(), $matches)) { $xangaPostID = $matches[1];[/code]I am trying to parse the post ID number from my xanga page. I am not sure why the (\d+) isn't working , since the post ID is simply everything after the edg176/.The whole url usually looks like this: http://www.xanga.com/edg176/nnn/xxx.htmlI'm trying to get the nnn out of the posts. Thanks Link to comment https://forums.phpfreaks.com/topic/13690-preg_match-to-parse-a-post-id/ Share on other sites More sharing options...
toplay Posted July 5, 2006 Share Posted July 5, 2006 That should work, but you want to use preg_match_all() to get all the values and then reference them like $matches[1][0], $matches[1][1], $matches[1][2], etc. Link to comment https://forums.phpfreaks.com/topic/13690-preg_match-to-parse-a-post-id/#findComment-53123 Share on other sites More sharing options...
wuwei101 Posted July 7, 2006 Author Share Posted July 7, 2006 Thanks. I've read the documentation in the php manual for preg_match_all and I'm confused about what the set of 2 flags means. Link to comment https://forums.phpfreaks.com/topic/13690-preg_match-to-parse-a-post-id/#findComment-54559 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.