word wrap without breaking HTML code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jrucifer
Forum Commoner
Posts: 32
Joined: Fri May 13, 2005 2:36 pm
Location: phoenix

word wrap without breaking HTML code

Post by jrucifer »

I have a website that is updated by a group of users, and if they ever copy and paste a URL, it breaks the tables. I've tried using word wrap, but then it breaks any long html code. Logically, it seems like the best solution would be to exclude anything in the < > brackets from being wrapped, but I'm not skilled enough in PHP to put the code together. Any simple solutions? Thanks for any help.
User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

Post by Todd_Z »

sounds like a problem that regular expressions can fix. Using an expression, you can split the html code after a certain amount of characters and when a html tag is not open. Look into that for the solution. I would write it for you, as its an interesting regex, buuuuut I'm about to fall asleep at the keyboard.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Why not automatically shorten the text used for the URL if it matches the URL? There are various methods to do this but which to use depends on how the URL is being handled by your script. Could you post a literal sample of what could be pasted?
Post Reply