Hello, I really suck when it comes to programming, but I want to make a small update on the script I purchased. What Happens is that if the word is let's say more then 8 letters it'll DOT after 8. Example: Chocolate Bunny will be come Chocolat... I want to change it to <br /> after 10 letters... any help? Thanks in advanced... here is the snip function insert_cutText($array){ $text = @$array["un"]; $useDot == "" ? $useDot = true : $useDot = false ; $size == "" ? $size = 100 : $size = $size ; $dot = ""; if ($useDot == "true"){$dot = "...";} if ((strlen($text)-1) <= $size){ $dot = ""; } return substr($text,0,$size).$dot; } function insert_removeBold($text){ $text = $text["un"]; $text = str_replace("<b>", "", "$text"); $text = str_replace("<b>", "", "$text"); return $text; } PHP:
Try this function insert_cutText($array){ $text = @$array["un"]; $useDot == "" ? $useDot = true : $useDot = false ; $size == "" ? $size = 100 : $size = $size ; $dot = ""; if ($useDot == "true"){$dot = "...";} if ((strlen($text)-1) <= $size){ $dot = ""; } return substr($text,0,$size).$dot.'<br />'; } function insert_removeBold($text){ $text = $text["un"]; $text = str_replace("<b>", "", "$text"); $text = str_replace("<b>", "", "$text"); return $text; } PHP:
no, that didn't really work... Bascailly what I want this little snip to do is instread of Chocolate Bunny To turn to Chocolat... To be: Chocolat e Bunny Thanks for your help
You mean like this one? function insert_cutText($array){ $text = @$array["un"]; $newtext = ''; $counter = 0; while ( strlen($text) > 0) { if ($counter > 0 ) { $newtext .= '<br />'; } $temp = substr($text,8); echo $temp; $newtext .= substr($text,0,8); $text=$temp; $counter++; } return $newtext; } PHP:
that seems to be correct, but for some reason when I put it in there, the page goes blank.... don't know what I'm doing wrong :S
try this one. function insert_cutText($array){ $text = @$array["un"]; $newtext = ''; $counter = 0; while ( strlen($text) > 0) { if ($counter > 0 ) { $newtext .= '<br />'; } $temp = substr($text,8); $newtext .= substr($text,0,8); $text=$temp; $counter++; } return $newtext; } PHP: