Jump to content

RSS string parse


gametopius

Recommended Posts

I am attempting to modify the rss.php file in my CMS. I would like it to display the first 250 characters of the stories description. But if the 250 is not empty I would like the character limit to increase until it finds the next open space. Here is a snipet of my code. Any help will be greatly appreciated and thank you for your time.

 

if ($row->fulltext == "")
     $itemDesc = $row->introtext != "" ? $row->introtext : "No description";
 else
$itemDesc = $row->introtext . $row->fulltext;	
$length = 250
$desc_length_max = $length;
$itemDesc = strip_tags($itemDesc, '<p> <br /> <br/> <br> <u> <i> <b> <img>');
$actualDescLength = strlen($itemDesc);
parse_str (string $itemDesc [, array &$arr])
$itemDesc = substr($itemDesc, 0, $desc_length_max);
$itemDesc = preg_replace("/\r\n|\n|\r/", "<br/>", $itemDesc);

if ($arr[$desc_lenght_max] != " ") ($length + 1) ($itemDesc .= " [...]");

Else
    $length = 250;
				    

 

Link to comment
https://forums.phpfreaks.com/topic/153662-rss-string-parse/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.