Results 1 to 2 of 2
Mar 17, 2009, 05: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, 12:05 #2
- Join Date
- Jul 2005
- West Springfield, Massachusetts
- 198 Post(s)
- 3 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.Big Change Coming Soon - if you want your PMs save them now!
What you need to do to prepare for our migration to Discourse
A New SitePoint Forum Experience: Our Move to Discourse