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. Link to comment https://forums.phpfreaks.com/topic/90661-displaying-part-of-a-field-content/ 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! Link to comment https://forums.phpfreaks.com/topic/90661-displaying-part-of-a-field-content/#findComment-464711 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.