Results 1 to 2 of 2
Mar 17, 2009, 04:31 #1
- Join Date
- Sep 2008
- 0 Post(s)
- 0 Thread(s)
XML News feed & displaying first line of news as a summary
Need your advice to solve my problem.
I am adding news feed on a website. Have stored those news feeds on local database using file read & loading xml into dom object.
News feeds do not have summary. Content get stored in $content usingCode:
$ContentsNd = xpath_eval($temp, "/Contents"); $content = $ContentsNd->nodeset->get_content();
But as I do not have summary for news article in xml feed, I am using following code to add few lines from content -
so i was thinking its better way to put first line of each article as a summary.
But dont have any idea about any built in function which I can use to do this.
So pls help me. Thanks in advance for your time.
Mar 17, 2009, 11:05 #2
- Join Date
- Jul 2005
- West Springfield, Massachusetts
- 146 Post(s)
- 1 Thread(s)
Yes, truncating a string at a set length can have undesirable results. You can always use strrpos() "string reverse position" to find the first "space" backwards from a certain length and then use substr() "substring" to get an excerpt terminating at that space.