Mr Chris Posted October 30, 2006 Share Posted October 30, 2006 Hi Guys,In PHP I was wondering:1) If there is a function which lets me output a set amount of words from a text field in a MYSQL database (and if so can someone can provide a link ;D )2) If I have the text saved in the DB as <b>This is the first paragraph<break></b> Is there any way I can get php to say output all the words until you see the first <break> then stop outputting?Thanks Link to comment https://forums.phpfreaks.com/topic/25582-output-a-set-number-of-words/ Share on other sites More sharing options...
alpine Posted October 30, 2006 Share Posted October 30, 2006 Two examples:[code]<?php$string = "abah ashb ashb asadyuci <break>ajkshdkj asduiqw hqwjd </break>sjakj asjkuq";$parts = explode("<break>",$string);echo $parts[0]; // output: abah ashb ashb asadyuciecho join(" ", array_slice(explode(" ", $string), 0, 2)); // output: abah ashb?>[/code] Link to comment https://forums.phpfreaks.com/topic/25582-output-a-set-number-of-words/#findComment-116805 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.