Jump to content

WordWraping function


lead2gold

Recommended Posts

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 deserve

FUNCTION:
[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 deep

DESIRED 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?
Link to comment
Share on other sites

[!--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

Edit: Sorry for the double post, i thought my browser froze so i pressed back, and saved it again
Link to comment
Share on other sites

[!--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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.