954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

add space in a string

I have been working on this for 2 days now. I have a form with a text box that allows 180 characters, if a user types in something with no spaces it wrecks my site since there is no space for the text to wrap in the table cell when it displays. I'm trying to come up with a regular expression that checks for spaces in the string, and if there are no spaces, to add a space after 50 characters this way the text will wrap properly. All my searches have lead me to trim() but I'm not trying to remove space. anyone have any ideas?

mission_PHP
Newbie Poster
2 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

A great thing about PHP is that because it's so chock-full of crap functions sometimes you find one that's useful :P

php.net/wordwrap

ShawnCplus
Code Monkey
Team Colleague
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268
 

A great thing about PHP is that because it's so chock-full of crap functions sometimes you find one that's useful :P

php.net/wordwrap

Sweet, here I was going the long way around it. I had no idea PHP had that function built in. This worked like a champ for me. There is so much to learn about PHP.

mission_PHP
Newbie Poster
2 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You