corillo181 Posted October 8, 2007 Share Posted October 8, 2007 how do i limit a paragraph to a set number. like if i got a strory and i only want 15 words to show how would i do it? i got it stared but ran out of idea. <?php function shortBio($id,$length){ $query="SELECT bio FROM tra_artist WHERE artist_id='$id'"; $result=$this->db->query($query); $txt = $this->db->fetch_array($result); $newtxt =explode(" ",$txt['bio']); $count = count($newtxt); } ?> Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 8, 2007 Share Posted October 8, 2007 http://www.php.net/manual/en/function.wordwrap.php Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted October 8, 2007 Share Posted October 8, 2007 <?php $newtxt =explode(" ",$txt['bio']); for ($i=0; $i<15; $i++){ echo $newtxt[$i].' '; } ?> There could be a better way...but that works. Teng84 - They didn't say they wanted 15 words per LINE, they want 15 words total. At least from what I understand. Quote Link to comment Share on other sites More sharing options...
corillo181 Posted October 8, 2007 Author Share Posted October 8, 2007 thats wha ti have in mind but how do i put that in a return? Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 8, 2007 Share Posted October 8, 2007 <?php $newtxt =explode(" ",$txt['bio']); for ($i=0; $i<15; $i++){ echo $newtxt[$i].' '; } ?> There could be a better way...but that works. Teng84 - They didn't say they wanted 15 words per LINE, they want 15 words total. At least from what I understand. ohh yah but this might be usefull look you dont know how long each words Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 8, 2007 Share Posted October 8, 2007 <? function shortBio($id,$length){ $query="SELECT bio FROM tra_artist WHERE artist_id='$id'"; $result=$this->db->query($query); $txt = $this->db->fetch_array($result); $newtxt =explode(" ",$txt['bio']); if (count($newtxt)<15){ return $txt['bio'];} else{ for($x=0;$x<15;$x++){ $words .= $newtxt[$x]; } return $words; } } ?> Quote Link to comment Share on other sites More sharing options...
corillo181 Posted October 8, 2007 Author Share Posted October 8, 2007 yeah man.. i don't know whats wrong with me, it's maybe because the Yankees are loosing that i don't seen to remember anything.. lol Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted October 8, 2007 Share Posted October 8, 2007 yeah man.. i don't know whats wrong with me, it's maybe because the Yankees are loosing that i don't seen to remember anything.. lol Yeah, that can do it =] The Broncos lost tonight, and I'm still angry Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 8, 2007 Share Posted October 8, 2007 solved? Quote Link to comment Share on other sites More sharing options...
corillo181 Posted October 8, 2007 Author Share Posted October 8, 2007 yes solved :| man people can't express anger in here.. anyways Yankees got the lead so now i can work calmly !!!! Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 8, 2007 Share Posted October 8, 2007 men i cant relate with your yankesssssss maybe post your expression in our miscellaneous section 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.