devofash Posted October 24, 2006 Share Posted October 24, 2006 hello... rite will get straight to the point. I got a paragraph in mysql field, I want to skip the first 100 words and display the rest of the paragraph on a page. how would I do this using php ?hope someone will be able to help me out. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/24970-skip-first-100-words/ Share on other sites More sharing options...
gmwebs Posted October 24, 2006 Share Posted October 24, 2006 I have an example where I have an array that I wanted to do this for.[code]<?php$text = "Whatever is in your DB field...";$offset = "100"; //The amount of words to skip...$newtext = skipWords($text, $offset);function skipWords($text, $offset) { $words = explode(' ', $text);//If the total amount of words are less than the offset, then just return the whole string if (count($words) > $offset) { return implode(' ', array_slice($words, $offset)); } else { return $text; } }?>[/code]Assuming you are pulling the record into an array, then you could do this. Link to comment https://forums.phpfreaks.com/topic/24970-skip-first-100-words/#findComment-113825 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.