Jump to content

skip first 100 words ...


devofash

Recommended Posts

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

Archived

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

×
×
  • Create New...

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.