redarrow Posted July 24, 2006 Share Posted July 24, 2006 how do i add a brake from the database when echo the letters out.so if there was a sentence with 200 letters how do i get a brake in there afther 50 letters cheers. Quote Link to comment https://forums.phpfreaks.com/topic/15438-edit-is-this-code-correct-does-not-work-substr-cheers/ Share on other sites More sharing options...
trq Posted July 24, 2006 Share Posted July 24, 2006 [url=http://php.net/wordwrap]wordwrap[/url]() might help you. Quote Link to comment https://forums.phpfreaks.com/topic/15438-edit-is-this-code-correct-does-not-work-substr-cheers/#findComment-62581 Share on other sites More sharing options...
redarrow Posted July 24, 2006 Author Share Posted July 24, 2006 I had an idear it was wordwrap can you kindly exsplain what the 1 for cheers.<?$word=array("12345678901234567890123456789012345678901234567890123324342343");foreach($word AS $a);$result=wordwrap($a,50,"<br>",1);echo $result;?> Quote Link to comment https://forums.phpfreaks.com/topic/15438-edit-is-this-code-correct-does-not-work-substr-cheers/#findComment-62589 Share on other sites More sharing options...
trq Posted July 24, 2006 Share Posted July 24, 2006 [quote]can you kindly exsplain what the 1 for cheers[/quote]The [url=http://php.net/wordwrap]manual[/url] does a fine job of explaining it. What more can I say? Quote Link to comment https://forums.phpfreaks.com/topic/15438-edit-is-this-code-correct-does-not-work-substr-cheers/#findComment-62594 Share on other sites More sharing options...
redarrow Posted July 24, 2006 Author Share Posted July 24, 2006 Is there a php statement that i can work out how to have only the amount of charecters i wont cheers. Quote Link to comment https://forums.phpfreaks.com/topic/15438-edit-is-this-code-correct-does-not-work-substr-cheers/#findComment-62600 Share on other sites More sharing options...
trq Posted July 24, 2006 Share Posted July 24, 2006 Please explain? Quote Link to comment https://forums.phpfreaks.com/topic/15438-edit-is-this-code-correct-does-not-work-substr-cheers/#findComment-62601 Share on other sites More sharing options...
redarrow Posted July 24, 2006 Author Share Posted July 24, 2006 i wont to find a way to specefi how many charecters to show from the database.i wont to learn the code properly but i wont to use if possable a php statement like the wordwrap easy and stright foward. Quote Link to comment https://forums.phpfreaks.com/topic/15438-edit-is-this-code-correct-does-not-work-substr-cheers/#findComment-62605 Share on other sites More sharing options...
trq Posted July 24, 2006 Share Posted July 24, 2006 Um... ive allready pointed you to the wordwrap manual twice. What part don't you understand? Quote Link to comment https://forums.phpfreaks.com/topic/15438-edit-is-this-code-correct-does-not-work-substr-cheers/#findComment-62610 Share on other sites More sharing options...
redarrow Posted July 24, 2006 Author Share Posted July 24, 2006 I got word wrap working cheers.this word wrap is for making a brake or new line i also was wanting substr ok but cheers.ps. if you know of a way to get word wrap to preform like substr show me cheers.$word=array("11111111112222222222");foreach($word AS $a);$result=wordwrap($a,10,"<br>",1);echo $result;For example say i wanted to show the first 10 numbers only can word wrap do it? . Quote Link to comment https://forums.phpfreaks.com/topic/15438-edit-is-this-code-correct-does-not-work-substr-cheers/#findComment-62613 Share on other sites More sharing options...
trq Posted July 24, 2006 Share Posted July 24, 2006 [quote]For example say i wanted to show the first 10 numbers only can word wrap do it?[/quote]No... use [url=http://php.net/substr]substr[/url](). Quote Link to comment https://forums.phpfreaks.com/topic/15438-edit-is-this-code-correct-does-not-work-substr-cheers/#findComment-62628 Share on other sites More sharing options...
redarrow Posted July 24, 2006 Author Share Posted July 24, 2006 can someone show me kindly what i done wrong please cheers.<?$word=array("11111111112222222222");for($i=0; $i<count($word); $i++){$word=$word[$i];}$text = "$word"; echo ShortenString($text); function ShortenString($text) { // Number of characters you want to display $num_chars = 19; $text = $text." "; $text = substr($text,0,$num_chars); $text = substr($text,0,strrpos($text,' ')); return $text; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/15438-edit-is-this-code-correct-does-not-work-substr-cheers/#findComment-62642 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.