forzatio Posted February 4, 2007 Share Posted February 4, 2007 Hi there, Im getting some rss feeds to display on my site however the source rss contains bold text which I can't get away. I tried to make a stylesheet that would set the text to normal but this doesn;t work, also I tried to put something like this in the echo: <p class=\"nobold\">$description</p> but still I get bold text. This is my code. <p class="nobold"> <?php include ('includewebsite.php'); ?> </p> foreach ($rss->items as $item ) { $description = str_ireplace('badword','goodword',$item[description]); $url = $item[link]; $title = str_ireplace('badword','goodword',$item[title]); echo "$title<br><br><p class=\"nobold\">$description</p><br><br>"; } Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 4, 2007 Share Posted February 4, 2007 for your stylesheet idea, did you try b{ text-weight: normal; } That should work. Quote Link to comment Share on other sites More sharing options...
forzatio Posted February 4, 2007 Author Share Posted February 4, 2007 I tried it but it keeps being bold, the rss has bold with <b> for the words in it's source, would there be a way to filter that tag out. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 4, 2007 Share Posted February 4, 2007 So if you add the style I posted it should change any bold text to normal. If the only tag in it is the bold tag, you can use strip_tags(). Or you can use strip_tags() and allow br, p, etc. Quote Link to comment Share on other sites More sharing options...
forzatio Posted February 4, 2007 Author Share Posted February 4, 2007 Ok I tried it this way in my includefile which retrieves the rss. in this case, it should remove the tag from the rss it needs to retrieve. foreach ($rss->items as $item ) { $description = str_ireplace('badword','goodword',strip_tags($item[description], '<b>')); The CSS font weight didn't work too. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 4, 2007 Share Posted February 4, 2007 the second argument of strip_tags() is allowed tags. You told it to strip every tag BUT <b> . What are you replacing with str_ireplace? Quote Link to comment Share on other sites More sharing options...
corbin Posted February 4, 2007 Share Posted February 4, 2007 you could always just feed the entire rss page into a variable then do $var = str_replace("<b>", "", $var); $var = str_replace("</b>", "", $var); Quote Link to comment Share on other sites More sharing options...
forzatio Posted February 4, 2007 Author Share Posted February 4, 2007 the second argument of strip_tags() is allowed tags. You told it to strip every tag BUT <b> . What are you replacing with str_ireplace? I tried it like this now and it seems to work now. foreach ($rss->items as $item ) { $description = str_ireplace('badword','goodword',strip_tags($item[description], '<b>')); They didn't use bold <b> with that tag. I use the str_ireplace (another thing) to replace some words from the RSS feed. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 4, 2007 Share Posted February 4, 2007 You're not making any sense. If you want to remove the bold tag, you can't put it as the second argument of strip_tags(). If they didn't use the b tag, what tag did they use to make it bold? strong? Either way, just use strip_tags() with NO second argument. Quote Link to comment Share on other sites More sharing options...
forzatio Posted February 4, 2007 Author Share Posted February 4, 2007 You're not making any sense. If you want to remove the bold tag, you can't put it as the second argument of strip_tags(). If they didn't use the b tag, what tag did they use to make it bold? strong? Either way, just use strip_tags() with NO second argument. ah yeah, in my case it's a totally coincidence, so I allowed '<b>' as a tag, while all other tags are now just stripped out.. the only tag in the RSS was <b> so it just solved the problem with total coincidence. how would I normally strip out the <b> tag and allow all other ? I just had some luck there Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 4, 2007 Share Posted February 4, 2007 just use str_replace() to replace '<b>' and '</b>' with '' Quote Link to comment 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.