Solved

cannot replace ? with £ in external RSS feed

Posted on 2007-04-03
4
236 Views
Last Modified: 2008-02-26
ive got a RSS feed displaying on the frontpage of this site:

http://www.quest-recruiting.com/

notice that the £ signs show as ? .  im using magpie rss feed scripts and they work well except i cant seem to get the ? replaced with a £ or £!!  I have tried everything:

$url = 'http://business.scotsman.com/topics.cfm?format=rss&tid=181';
$rss = fetch_rss($url);
$limit = rand(0,count($rss->items));

foreach($rss->items as $item)
{
      $rss_description = $item['description'];
      $rss_title = $item['title'];
      
      /*
      $rss_title = str_replace('‘',''',$rss_title);                  
      $rss_title = str_replace('’',''',$rss_title);                
      $rss_title = str_replace('‚',',',$rss_title);                
      $rss_title = str_replace('“','"',$rss_title);                
      $rss_title = str_replace('”','"',$rss_title);                
      $rss_title = str_replace('"','"',$rss_title);                                           
      $rss_title = str_replace('¼','¼',$rss_title);                     
      $rss_title = str_replace('½','½',$rss_title);        
      $rss_title = str_replace('¾','¾',$rss_title);
      $rss_title = str_replace("'","'",$rss_title);
      $rss_title = str_replace('—','-',$rss_title);
      $rss_title = str_replace(' — ',' - ',$rss_title);
      $rss_title = str_replace('  ',' ',$rss_title);
      $rss_title = str_replace('£','£',$rss_title);
      */
      
      $rss_title = str_replace('?','£',$rss_title);
      
      $rss_description = removeEvilTags($rss_description);
      
      /*
      $rss_description = str_replace('‘',''',$rss_description);                  
      $rss_description = str_replace('’',''',$rss_description);                
      $rss_description = str_replace('‚',',',$rss_description);                
      $rss_description = str_replace('“','"',$rss_description);                
      $rss_description = str_replace('”','"',$rss_description);                
      $rss_description = str_replace('"','"',$rss_description);                                           
      $rss_description = str_replace('¼','¼',$rss_description);                     
      $rss_description = str_replace('½','½',$rss_description);        
      $rss_description = str_replace('¾','¾',$rss_description);
      $rss_description = str_replace("'","'",$rss_description);
      $rss_description = str_replace('—','-',$rss_description);
      $rss_description = str_replace(' — ',' - ',$rss_description);
      $rss_description = str_replace('  ',' ',$rss_description);
      $rss_description = str_replace('£','£',$rss_description);
      */
      
      $rss_description = str_replace('?','£',$rss_description);
      
      $s_HtmlContent .= '<h3 class="news_feeds"><a href="'.$item['link'].'" title="'.$rss_title.'" onclick="javascript:window.open(this.href);return false;">'.$rss_title.'</a></h3>'."\n";
      $s_HtmlContent .= '<p class="news_feeds">'.nl2br($rss_description).'</p>'."\n";
      
      if(--$limit < 1)
      {
            break;
      }
}

the removeEvilTags() function just remove <img> tags and other tags that i dont want...

please help.
0
Comment
Question by:ellandrd
  • 2
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
richswyatt earned 500 total points
ID: 18842744
I would try using the html_entities or html_special_chars function on $rss_description PRIOR to the str_replaces.

This will ensure that the symbol is in a format that can be 'found' in the str_replace. I've run into this before and that was the solution.

~Rich
0
 
LVL 16

Author Comment

by:ellandrd
ID: 18842769
i will give it a try. if it works i will kick myself as i never though of trying these functions....
0
 
LVL 16

Author Comment

by:ellandrd
ID: 18842874
htmlentities() worked!

thank you so much!
0
 
LVL 5

Expert Comment

by:richswyatt
ID: 18842879
You're welcome. The little things always get us. :-)
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now