chinclub Posted September 16, 2013 Share Posted September 16, 2013 I am writing a simple blog script. I have been looking for a tutorial that goes beyond the very basics. The one thing I can't find a code for is how to deal with the line break that tells the script to stop there and add the (Read more) link. In my basic php knowledge I know I could just have two seperate fields in the post column, one for the intro part and one for the remainder of the article. I was wondering if this was the right way or if there was something easier. Any help would be great. Link to comment https://forums.phpfreaks.com/topic/282201-blog-read-more-feature/ Share on other sites More sharing options...
drisate Posted September 16, 2013 Share Posted September 16, 2013 You can use explode()In your txt you can use BBCode Ex: $txt = 'balbalbalbal[***]blablablablala 111';$txt = explode('[***]', $txt); echo "First part: $txt[0]<br>"; echo "Rest of it: $txt[1]"; You can also cut after a certain number of characters or after a certain number of words or phrases. after 10 charcaters: $string = substr($string,0,10).'...'; After x number of wordshttp://www.lullabot.com/blog/article/trim-string-given-word-countAfter x number of phraseshttp://gelembjuk.com/index.php?option=com_content&view=article&id=61:split-text-for-sentences-with-php&catid=37:php&Itemid=56 Link to comment https://forums.phpfreaks.com/topic/282201-blog-read-more-feature/#findComment-1449760 Share on other sites More sharing options...
chinclub Posted September 16, 2013 Author Share Posted September 16, 2013 Thanks, that was very helpful! Link to comment https://forums.phpfreaks.com/topic/282201-blog-read-more-feature/#findComment-1449771 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.