PDA

View Full Version : Strip Everything except [IMG]url[/IMG] tag


OnyxChase
02-27-2008, 12:10 AM
Hi guys, I am hoping that you could help me. I have been googleing for over 2 hours and haven't found my solution.

I am creating a custom search which will enable me to search for all [ IMG]http://www.url.com[/IMG ].

But since I am pulling the information directly from vbulletin.post.pagetext, I am left with entire posts.

Is there a PHP function to strip everything except the [ IMG]http://url.com[/IMG ] tags?

Thanks in advanced,

Sincerely,
Jean

shovel
02-27-2008, 05:07 PM
Regular expressions will be your friend..

preg_match('/\\[img\\](.+?)\\[\\\/img\\]/i', $subject, $matchedArray);

OnyxChase
02-27-2008, 05:39 PM
Thanks for your help! But I am getting an error when using it,

Warning: preg_match() [function.preg-match]: Unknown modifier 'g' in /search_media.php on line 88

I tried looking at the preg_match manual but couldn't fix the problem, I will look at it again.

shovel
02-27-2008, 05:58 PM
Actually you should probably use "preg_match_all" because we are looking for multiples rather singular.

preg_match_all('/\\[img\\](.+?)\\[\\\/img\\]/i', $subject, $matchedArray);

OnyxChase
02-27-2008, 08:04 PM
I am still getting this error:

Warning: preg_match_all() [function.preg-match-all]: Unknown modifier 'g' in /search_media.php on line 92

I must be doing something wrong here... MMM, I'll try looking at the manual again. Thanks for your help. :)