Splitting up bulk text
Started by Lang, May 07 2006 04:58 PM
9 replies to this topic
#1
Posted 07 May 2006 - 04:58 PM
Ok, so someone posts a comment. Its along the lines of
"This is so COOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOL"
And completely destroys my beautiful page.
I've tried wordwrap(); didn't work. Does anyone know of a way I can split stupid things like that up?
Thanks in advance,
"This is so COOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOL"
And completely destroys my beautiful page.
I've tried wordwrap(); didn't work. Does anyone know of a way I can split stupid things like that up?
Thanks in advance,
#2
Posted 07 May 2006 - 05:24 PM
<?php
$string = "HERE IS THE TEXT";
$regex = "/([0-9]{0,2}:[0-9]{0,2})(STUFF HERE/";
$replace = "<br />$1$2";
$filter = preg_replace($regex, $replace, $string);
$entries = explode("<br />", $filter);
sort($entries);
unset($entries[0]);
foreach ($entries AS $entry)
{
echo $entry . "<br />";
}
?>
I have no idea if this will work. I edited off somebody elses REGIX script, I do not understand it fully.
Edited by DanWilliamson, 07 May 2006 - 05:25 PM.
#3
Posted 07 May 2006 - 05:50 PM
Cant you just do something like
if the word is longer than 20 charaters, it will strip it down to 18 characters and add 3 dots at the end.
Why didnt wordwrap work btw?
i think thats the ideal solution for this problem, i think this is what they made it for after all.
if(str_len($string) > 20){
$string = substr($string, 0, 18).'...';
}
if the word is longer than 20 charaters, it will strip it down to 18 characters and add 3 dots at the end.
Why didnt wordwrap work btw?
i think thats the ideal solution for this problem, i think this is what they made it for after all.
#4
Posted 07 May 2006 - 06:25 PM
Avalanche, on May 7 2006, 06:50 PM, said:
Cant you just do something like
if the word is longer than 20 charaters, it will strip it down to 18 characters and add 3 dots at the end.
Why didnt wordwrap work btw?
i think thats the ideal solution for this problem, i think this is what they made it for after all.
if(str_len($string) > 20){
$string = substr($string, 0, 18).'...';
}
if the word is longer than 20 charaters, it will strip it down to 18 characters and add 3 dots at the end.
Why didnt wordwrap work btw?
i think thats the ideal solution for this problem, i think this is what they made it for after all.
I have no idea why wordwrap didn't work =P If I knew that I would be finding an answer to it =P
And DanWilliamson, I tried that piece of code and it didn't work. Some comments didn't even show up.
[EDIT] I got the piece of code to work by removing unset($entries[0]);
I really don't know why that was there. But it got rid of the first entry in the array which seemed stupid.
Edited by Lang, 07 May 2006 - 07:00 PM.
#5
Posted 07 May 2006 - 06:33 PM
show us the way you used wordwrap.
#6
Posted 08 May 2006 - 10:10 AM
hey, btw, cant you just use CSS so the column does not expand
<td style"table-layout:fixed;">
try that
<td style"table-layout:fixed;">
try that
#7
Posted 08 May 2006 - 04:03 PM
echo wordwrap($text, 150);
Thanks for that Avalanche, i'll try that too. If I used that it'd lower file size.
#8
Posted 08 May 2006 - 05:34 PM
150 is too big, thats probably why
#9
Posted 09 May 2006 - 05:50 AM
i think you confused 150 pixels with 150 characters.
#10
Posted 09 May 2006 - 03:27 PM
I didn't actually use 150. Its just a number I plugged in there.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
