Jump to content

Archived

This topic is now archived and is closed to further replies.

devofash

skip first 100 words ...

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.