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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.