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

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -