nduaj Posted February 12, 2008 Share Posted February 12, 2008 hello, I recently developed a news website, but i have a questions: on the home page, i want to show just previews of the news (mabe 50 - 100 words) from the story field of my news table in the databsae. my question is, how do i display on 50 words from the content of the field table. thanks. Quote Link to comment Share on other sites More sharing options...
PHP Monkeh Posted February 12, 2008 Share Posted February 12, 2008 There's probably a better way of doing this, but you could explode your current string by a space, creating an array of the words in the string. Then you could loop through and echo the first 50 array values: $string = $r->content; // Content pulled from the database $temp = explode(" ", $string); // Explode the content string for($i=0; $i<50; $i++) { echo $temp[$i]; } Like I said, there's probably a much easier way - I just don't know about it! 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.