Page 1 of 1

wordwrap(); function

Posted: Wed May 26, 2004 5:22 am
by duk
hy,

i use wordwarp function to put a <br> tag, after 53 caracters, becouse i want that any post, that someones do, do not exceed, the limit of the html table...

but the problem is, that if i put 60 "g" caracters, works fine, but if i put 60 "f" caracters, will not work very fine...

my objective is format the text to not, expand the html table...

if i use

Code: Select all

<?php

echo "
<table border=1>
<td>hello</td>
</table>

";

?>
this appear a litle table, but if i put helllllllllllllllloooooooooooooooo, the table will expand, and i dont want this to happen, so i need to put a <br> tag, after x caracters, so the table will be with the width that i want... like post for foruns etc...

i use nl2br(); wordwrap(); and the htmlspecialcaracter(); functions, but i still have the problems...

anyone knows a good way to not permite that a html table expands, by having a lot of caracters ???

sorry my english
regards
duk

Posted: Wed May 26, 2004 6:30 am
by kevin7
hmm... i think php won't solve ur problem...

u can try to set the width of the table... or try put percentage...

<TABLE width=200>

or

<TABLE width=20%>

..... :wink:

Posted: Wed May 26, 2004 7:07 am
by duk
:( i make a fiew teste right now, the problem persists, the table expands, if i make this

<table border=1 width="10%">

<td>kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk</td>
</table>

but still, expands...

like all see the table from thsi forum, expands too LOL so i want to stop this to happen... anyone knows ???

Posted: Wed May 26, 2004 9:56 am
by launchcode
Here, I use this in my forum software - it should do what you want (but tailor the numbers to fit your page design)

Code: Select all

//	Proportional spaces check. For every 10 characters there should be 1 space
        if (substr_count($subject, " ") < floor(strlen($subject)/10)) { return 37; }
The Return just kicks back an error message - but you could use it to split the string up yourself.

Posted: Wed May 26, 2004 10:42 am
by duk
but this code will check if you have a space after 10 caracters, but if you dont have a space, he will put the space ???

is correct ??? if not, explain more this code pls :)

Posted: Wed May 26, 2004 10:46 am
by kettle_drum
Theres not much that you can do about it, its better to have it start a new line when there is a space so that you avoid splitting words up, but by counting so many letters will also work if you place "-" at the end of the line. You also need to make sure you do ive the table a true width such as 400, not 50%. You can also use css to ensure you dont excede, so have a play with that.

Posted: Wed May 26, 2004 10:54 am
by duk
so i can do anything very strange...

but about css, you have any example ??? a litle page with tuturials....

but i think i ill live the function wordwrap to put the <br> tag after x, caracters...