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
- 111 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.10 Rules for Driving Traffic Using Forums | Ultimate SEO Checklist
External links are nofollow
How to be a Great Online Community Member
Member of the Month for December 2013
Free SitePoint book - Thinking Web: Voices Of The Community
The 2013 SitePoint Awards - Nominations closed - Voting to begin soon
Introducing the new Code Review Forum