Jump to content

Help: Code to cut a line and go to the next


leonidas

Recommended Posts

hello! i run a mybb forum and they have the worst support forum so i decided to try my luck here...

 

i have this plugin code and what i want is when the line reachers 30 characters it will go to the next line...

 

here's the code --> 

$post['custom_status_shortened'] = (strlen($post['custom_status']) > 13) ? substr($post['custom_status'],0,30): $post['custom_status'];

thanks in advance to those who can help me... :)

If you have a string containing more than 30 utf characters (you might want to be careful with character counting for special entities, such as the exponential e which's unicode representation consists of two sequences rather than one, which ultimately affects strlen), you can create a copy of the remaining string using substr, then append \n to the string (eventually \r\n for email bodies or whatever), and then concatenate the strings again.

Just an idea.

If you have a string containing more than 30 utf characters (you might want to be careful with character counting for special entities, such as the exponential e which's unicode representation consists of two sequences rather than one, which ultimately affects strlen), you can create a copy of the remaining string using substr, then append \n to the string (eventually \r\n for email bodies or whatever), and then concatenate the strings again.

Just an idea.

 

hi! thanks for the reply... that's the problem, i don't know anything about coding... i just run a forum, hopefully somebody can help me here... :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.