lead2gold Posted March 10, 2006 Share Posted March 10, 2006 INPUT:Try to hold in and not show that you feel some coworkers are lazy scum and they should be disiplined severly or removed from service. I would like Eric to treat everyone as if they would decide his future, and in a way many others do decide our future. Eric from my point of view, you with little effort can work with everyone, and if you hold in your distain for poor work ethic's , we as a group can proceed together to become a team. Eric you have invested years of hard work, extra hours and helping others by switching holidays, days off and Saturdays and you are a very welcome member of our service department, but there is a cost of membership, which is what I am working on for myself as well; Treat others with respect at all times, even when we feel they may not deserve it. Learn new tools and ways of doing our job.(spg,ltw,you have aced ECP) Write your Toyota factory Service advisor exam, as always you can win a trip to compete in Canada and then Japan. Compete in overdrive contest. Do service advisor training with Toyota and tire makers , at Toyota u.OUTPUT:Try to hold in and not show that you feel some coworkers are lazy scum and they should be disiplined severly or removed from service. I would like Eric to treat everyone as if they would decide his future, and in a way many others do decide our future. Eric from my point of view, you with little effort can work with everyone, and if you hold in your distain for poor work ethic's , we as a group can proceed together to become a team. Eric you have invested years of hard work, extra hours and helping others by switching holidays, days off and Saturdays and you are a very welcome member of our service department, but there is a cost of membership, which is what I am working on for myself as well; Treat others with respect at all times, even when we feel they may not deserveFUNCTION:[code]function cc_truncate($string, $width, $max_cr){ $formatted_text = wordwrap($string,$width,"\n"); $complete_array = explode("\n",$formatted_text); //turns the string into an array $clean_array = array_slice($complete_array, 0, $max_cr); //takes the first max_cr elements (lines) of the array $clean_text = implode(" ",$clean_array); //puts the string back together, with \n after each element in the array return $clean_text;}[/code]CALL:[code]cc_truncate($a->new_objectives, 80,11)[/code]Thus: max characters of 80 wide, and 11 deepDESIRED OUTPUT:Try to hold in and not show that you feel some coworkers are lazy scum and they should be disiplined severly or removed from service. I would like Eric to treat everyone as if they would decide his future, and in a way many others do decide our future. Eric from my point of view, you with little effort can work with everyone, and if you hold in your distain for poor work ethic's , we as a group can proceed together to become a team. Eric you have invested years of hard work, extra hours and helping others by switching holidays, days off and Saturdays and you are a very welcome member of our service department, but there is a cost of membership, which is what I am working on for myself as well; Treat others with respect at all times, even when we feel they may not deserve it.<-- chopped off -->Learn new tools and ways of doing our job.(spg,ltw,you have aced ECP) Write your Toyota factory Service advisor exam, as always you can win a trip to compete in Canada and then Japan. Compete in overdrive contest. Do service advisor training with Toyota and tire makers , at Toyota u.----------------------------------------Thus after 80 characters, a new line is forced.What seems to be happening is that the existing carrage returns are also getting tangled up with the new carrage returns wordwrap() inserts. it seems wordwrap() ignores existing carrage returns and treats them like a regular character (thus wraps \n's at bizzare locations)How can i adjust the wordwrap function to achieve my goals? Quote Link to comment https://forums.phpfreaks.com/topic/4606-wordwraping-function/ Share on other sites More sharing options...
craygo Posted March 10, 2006 Share Posted March 10, 2006 you can add str_replace in first to remove all the carraige returns then use your existing wordwrap code.[code]$newstring = str_replace("\n", "", $string);[/code]Ray Quote Link to comment https://forums.phpfreaks.com/topic/4606-wordwraping-function/#findComment-16133 Share on other sites More sharing options...
lead2gold Posted March 10, 2006 Author Share Posted March 10, 2006 [!--quoteo(post=353626:date=Mar 10 2006, 09:46 AM:name=craygo)--][div class=\'quotetop\']QUOTE(craygo @ Mar 10 2006, 09:46 AM) [snapback]353626[/snapback][/div][div class=\'quotemain\'][!--quotec--]you can add str_replace in first to remove all the carraige returns then use your existing wordwrap code.[code]$newstring = str_replace("\n", "", $string);[/code]Ray[/quote]Thanks, but then all the formatting is lost.... :( I will use this for a temporary workaround i guess until i find a sollutionEdit: Sorry for the double post, i thought my browser froze so i pressed back, and saved it again Quote Link to comment https://forums.phpfreaks.com/topic/4606-wordwraping-function/#findComment-16181 Share on other sites More sharing options...
lead2gold Posted March 10, 2006 Author Share Posted March 10, 2006 [!--quoteo(post=353626:date=Mar 10 2006, 09:46 AM:name=craygo)--][div class=\'quotetop\']QUOTE(craygo @ Mar 10 2006, 09:46 AM) [snapback]353626[/snapback][/div][div class=\'quotemain\'][!--quotec--]you can add str_replace in first to remove all the carraige returns then use your existing wordwrap code.[code]$newstring = str_replace("\n", "", $string);[/code]Ray[/quote]Thanks, but then all the formatting is lost.... :( I will use this for a temporary workaround i guess until i find a sollution Quote Link to comment https://forums.phpfreaks.com/topic/4606-wordwraping-function/#findComment-16182 Share on other sites More sharing options...
Barand Posted March 11, 2006 Share Posted March 11, 2006 try[code]$paras = explode ("\n", $input);foreach ($paras as $p) { echo nl2br(wordwrap($p, 80));}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/4606-wordwraping-function/#findComment-16381 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.