Click to See Complete Forum and Search --> : Getting rid of br in a field ?


jeddik
08-06-2006, 01:54 PM
Hi,

I am trying to keep some displayed text within two lines,
so I want to only allow one <br> in the string.

Does anyone know to take out the rst of the <br> 's ?

So far I have this ( which reduces the number of characters)

$desc_sht = substr($desc_lng, 0, 140);

Any ideas ?

Thanks for any help. :)

shane.carr
08-09-2006, 08:13 PM
If there's a string like "This That This That <br> This That This That <br> This That This That <br>" then this code will take out all but the first <br>:


$var1 = "your text";
$var2 = explode("<br>", $var1);
if(sizeof($var2)>2){
str_replace("<br>", "", $var2[1]);
$var1 = implode("<br>", $var2);
}