ChemicalBliss Posted April 24, 2010 Share Posted April 24, 2010 You would set the result of the function to a variable, eg; $Result = advanced_index($skipped,$Sentence); $number_of_sentences_wanted = 2; // Then loop and echo the amount of sentences you want For($i=0;$i<$number_of_sentences_wanted;$i++){ echo($Result[$i]); } Though i would assume you want to limit length also; $Result = advanced_index($skipped,$Sentence); $number_of_characters_wanted = 30; // Then loop and echo the amount of sentences you want $word_array = array(); $characters = 0; Foreach($Result As $item){ $words = explode(" ",$item); for($i=0;$i<count($words);$i++){ // The 3 is for the 3 dots added. if((strlen($words[$i]) + $characters + 3) > $number_of_characters_wanted){ $word_array[] = "..."; break; }else{ $characters += strlen($words[$i]); $word_array[] = $words[$i]; } } } echo(implode(" ",$word_array)); -cb- Quote Link to comment https://forums.phpfreaks.com/topic/199303-explode-a-but-ignore-dr/page/2/#findComment-1047478 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.