Re: Getting a specific URL out of a string

2009-04-28 Thread starkey
You can use substr and strpos to get it. $ii = 0; $jj = 0; if (FALSE !== ($ii = strpos($url, 'twitpic.com'))) { $jj = strpos($url, '', $ii); $twitpicUrl = substr($url, $ii, ($jj-$ii)); } Or something like that. Shawn On Apr 28, 7:54 am, Kyle Decot kdec...@gmail.com wrote: I know this

Getting a specific URL out of a string

2009-04-28 Thread Kyle Decot
I know this isn't specifically a CakePHP question but I thought I would see any any of you could help me out anyways. I am getting a feed of Twitter updates and I want to check each one to see if it has a http://twitpic.com URL in it. How would I go about getting the TwitPic URL out of it? I

Re: Getting a specific URL out of a string

2009-04-28 Thread brian
This should match the URL followed by anything other than whitespace or double quote. $pattern = '/(http:\/\/twitpic\.com[^\s\]+)/'; preg_match($pattern, $str, $matches, PREG_SET_ORDER); debug($matches); On Tue, Apr 28, 2009 at 7:54 AM, Kyle Decot kdec...@gmail.com wrote: I know this isn't

Re: Getting a specific URL out of a string

2009-04-28 Thread Kyle Decot
What does PREG_SET_ORDER do exactly? When I use it I get a Invalid flags specified error. Thank Ideas? On Apr 28, 12:11 pm, brian bally.z...@gmail.com wrote: This should match the URL followed by anything other than whitespace or double quote. $pattern = '/(http:\/\/twitpic\.com[^\s\]+)/';

Re: Getting a specific URL out of a string

2009-04-28 Thread brian
Sorry, make that preg_match_all(). From the manual: PREG_SET_ORDER Orders results so that $matches[0] is an array of first set of matches, $matches[1] is an array of second set of matches, and so on. http://www.php.net/manual/en/function.preg-match-all.php On Tue, Apr 28, 2009 at 1:06 PM,