PKENGLISH Posted October 3, 2007 Share Posted October 3, 2007 Hi, I am creating an RSS feed reader in flash and in order to get around the sandbox regulations, I am using a php file to make the feed appear on the local server. The question I have is before I pass the data to the Flash file is it possible to strip out all the images that might be placed within the feed? I really dislike how flash's dynamic text fields handles them so I would rather get rid of them completely. I have been looking around at preg_replace but am not sure if that is the solution I should be using or really how to work it. I am still pretty new with PHP so any help would be greatly appreciated. The code that my current PHP files uses is as follows. <?php $feedURL = "http://somefeedurl.com/index.xml"; $getFeed = curl_init($feedURL); $result = curl_exec($getFeed); curl_close($getFeed); echo $result; ?> Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/71718-strip-image-tags-from-a-rss-feed/ Share on other sites More sharing options...
darkfreaks Posted October 3, 2007 Share Posted October 3, 2007 would something like <?php strip_tags($comment,'allowed tags here'); ?> work? every tag between the quotes would be allowed and everything else would be stripped Quote Link to comment https://forums.phpfreaks.com/topic/71718-strip-image-tags-from-a-rss-feed/#findComment-361108 Share on other sites More sharing options...
michaellunsford Posted October 3, 2007 Share Posted October 3, 2007 or <?php echo preg_replace("/<img[^>]+>/i","",$result); ?> Quote Link to comment https://forums.phpfreaks.com/topic/71718-strip-image-tags-from-a-rss-feed/#findComment-361118 Share on other sites More sharing options...
PKENGLISH Posted October 3, 2007 Author Share Posted October 3, 2007 I think that what I am looking for is the second option using preg_replace. When I place the code into the document however it doesn't seem to be working. Could the curl potentially cause problems with it? Quote Link to comment https://forums.phpfreaks.com/topic/71718-strip-image-tags-from-a-rss-feed/#findComment-361154 Share on other sites More sharing options...
darkfreaks Posted October 3, 2007 Share Posted October 3, 2007 whats it echoing? Quote Link to comment https://forums.phpfreaks.com/topic/71718-strip-image-tags-from-a-rss-feed/#findComment-361161 Share on other sites More sharing options...
darkfreaks Posted October 3, 2007 Share Posted October 3, 2007 i still think you should use string replace echo str_replace("/<img[^>]+>/i","",$result); or echo str_replace("<img src="">","",$result); or even echo strip_tags($result,'<p> <b> <allowed tags>') Quote Link to comment https://forums.phpfreaks.com/topic/71718-strip-image-tags-from-a-rss-feed/#findComment-361168 Share on other sites More sharing options...
PKENGLISH Posted October 3, 2007 Author Share Posted October 3, 2007 It seems to echo the exact same feed as i find on the site i got it from. This is my full code: <?php $feedURL = "http://www.geekologie.com/index.xml"; $getFeed = curl_init($feedURL); $result = curl_exec($getFeed); curl_close($getFeed); echo str_replace("/<img[^>]+>/i","",$result); ?> And this is what comes out as a result: http://www.jeffhirsch.net/RSS/antisandbox.php It seems to completely ignore the str_replace. Quote Link to comment https://forums.phpfreaks.com/topic/71718-strip-image-tags-from-a-rss-feed/#findComment-361177 Share on other sites More sharing options...
darkfreaks Posted October 3, 2007 Share Posted October 3, 2007 i get a 404 error? Lol Quote Link to comment https://forums.phpfreaks.com/topic/71718-strip-image-tags-from-a-rss-feed/#findComment-361179 Share on other sites More sharing options...
darkfreaks Posted October 3, 2007 Share Posted October 3, 2007 try using strip_tags($result,'allowed tags here'); Quote Link to comment https://forums.phpfreaks.com/topic/71718-strip-image-tags-from-a-rss-feed/#findComment-361180 Share on other sites More sharing options...
marcus Posted October 3, 2007 Share Posted October 3, 2007 Try just: echo strig_tags($string,"<b><i><em><strong><a><h1><h2><h3>"); //etc... Quote Link to comment https://forums.phpfreaks.com/topic/71718-strip-image-tags-from-a-rss-feed/#findComment-361182 Share on other sites More sharing options...
darkfreaks Posted October 3, 2007 Share Posted October 3, 2007 LOL havent i been saying that Quote Link to comment https://forums.phpfreaks.com/topic/71718-strip-image-tags-from-a-rss-feed/#findComment-361184 Share on other sites More sharing options...
marcus Posted October 3, 2007 Share Posted October 3, 2007 Maybe he doesn't like you Quote Link to comment https://forums.phpfreaks.com/topic/71718-strip-image-tags-from-a-rss-feed/#findComment-361186 Share on other sites More sharing options...
darkfreaks Posted October 3, 2007 Share Posted October 3, 2007 awww i feel so resented Quote Link to comment https://forums.phpfreaks.com/topic/71718-strip-image-tags-from-a-rss-feed/#findComment-361187 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.