Hello,
I have a setup where members can enter a description into a text field. I then send it through this function before storing in mysql.
function prepIn($input) {
$input = trim($input);
if (!get_magic_quotes_gpc()) {
return addslashes($input);
}
return $input;
}
I use this on the way out:
function prepOut($input) {
$input = stripslashes($input);
return htmlspecialchars($input);
}
And then:
$output= = prepOut($output);
$output= = nl2br($output);
I am limiting the amount of text displayed with this:
if(strlen($output) > 100){
$output= substr($output, 0,100);
echo "$output...;
}
else{
echo $output;
}
And here's my problem:
In the database there are entries stored with alot of "space" between them. I'm not sure if they are from repeated enter keys or an issue with posting from Word or something. The problem is that when there is a lot of empty space it looks bad to have the "..." appear after it.
How would I turn this:
This is the first two
lines of text
...
Into this:
This is the first two
lines of text...
I would also like to know how to get rid of so much space. Ideally would be to send it TO the database with no consecutive spaces and every paragraph break (or consectutive paragraph break) would be replaced with <br><br>.
Is this possible?
Thank you very much.