php - Extract url with .swf in the end from string -
i want extract url ending .swf using php.
example
test test test http://website.com/example.swf
i want url .swf
i used function preg_replace()
preg_replace('!http://[^?#]+\.(?:swf|swf)!ui','', $content);
but extract url + words after url
thanks..
after clarification on need think you.
preg_match_all('#(?p<url>https?://[^\s]+\.swf) (?p<description>[^\n]+)#uid', $content, $results); $data = []; foreach($results['url'] $key => $value) { $data[] = [ 'url' => $value, 'description' => $results['description'][$key] ]; } // here can put code saving data want. // if need replace content urls <object> tag: $content = preg_replace('#(https?://[^\s]+\.swf)#uid', '<object src="$1"></object>', $content);
Comments
Post a Comment