1

I'm pulling a feed from wordpress in php and loading it. No issues there but I'm getting these html entities in my text that I can't seem to strip out successfully. I just want the weird characters gone.

<?php

$feed = simplexml_load_file('http://www.partspro.com/blog/feed/');

function clean($string){
    //return preg_replace("/&#?[a-z0-9]+;/i","",$string);
    //$string = strip_tags($string);
    //return preg_replace('/[^a-zA-Z0-9_ %\/.()%&-]/s', '', $string);
    return html_entity_decode($string);
}

foreach ($feed->channel->item as $item) {
    $count++;
    $title = clean((string)$item->title);
    $link = (string)$item->link;
    $pubDate = (string)$item->pubDate;
        $pubDate = strtotime($pubDate);
        $pubDate = date('F j, Y, g:i a',$pubDate);
    $description = clean((string)$item->description);

    if ($count >= 5) {
        exit();
    } else {
        echo '<a href="' . $link . '" target="_blank"><h1>' . $title . '</h1></a>';
        echo '<em>' . $pubDate . '</em>';
        echo '<p>' . $description . '</p>';
    }
}

?>

I want characters like the ’ removed. What am I missing or doing wrong? Here is what is spitting out:

Edge Products’ Evolution CS/CTS Get Welcome Feature Update for Chevy/GMC Gas Vehicles

January 7, 2015, 11:14 am

For Evolution CS and CTS users who have been asking for an option to disable their units’ Active Fuel Management/Displacement on Demand (AFM/DOD) feature, your time has come. AFM/DOD, which appears on Evolution models PN 85150 and PN 85250 (covers 2007–2013 5.3L and 6.2L Chevy/GMC trucks and SUVs as well as 6.0L 2007–2010 1500 Chevy/GMC … Continue reading Edge Products’ Evolution CS/CTS Get Welcome Feature Update for Chevy/GMC Gas Vehicles

Edward
  • 5,942
  • 4
  • 38
  • 55
John Ayers
  • 509
  • 1
  • 11
  • 33

0 Answers0