I want to extract a url ending with .swf using php.
EXAMPLE
TEST TEST TEST http://website.com/example.swf
preg_replace()
preg_replace('!http://[^?#]+\.(?:swf|SWF)!Ui','', $content);
After some clarification on what you need i think this will help you.
preg_match_all('#(?P<url>https?://[^\s]+\.swf) (?P<description>[^\n]+)#uiD', $content, $results);
$data = [];
foreach($results['url'] as $key => $value) {
$data[] = [
'url' => $value,
'description' => $results['description'][$key]
];
}
// Here you can put your code for saving the data you want.
// if you need to replace the content urls with the <object> tag:
$content = preg_replace('#(https?://[^\s]+\.swf)#uiD', '<object src="$1"></object>', $content);