I have made a news script, but I now want to modify it so that it puts like 75 words insted of 500 characters followed by ..., I just think it looks crap.
I have created the code that should explode all the words by spaces ' ', and them stick that into a for loop that will count to 75 and stick them onto a variable including spaces.
$preview = explode(' ', $news['post']);
$i = 0;
$news['preview'] = '';
for($i = 0; $i > 250; $i++) {
$news['preview'] .= $preview[$i];
if($i != 249) $news['preview'] .= ' ';
}
for some reason when I output $news nothing comes out and I don't know why.
There are to two things I want to know.
1. Why is this simple script not working?
2. Is there a better way of doing this?