I am printing page content from a MYSQL db in PHP. I have a text field in db called $row['description']
When storing users input into db I only use mysql_real_escape_string() so I do not edit html
Problem is I use this field from db as the html pages meta description tag. So if user inserted line breaks in description they cause a line break in the source code of the page within the meta description tag. I tried to remove the line break by using a loop to skip an br formats. I use the nl2br to convert to br.
$desc_array=(explode(" ", $row['description']));
for($i=0; $i < 17;$i++){
if(nl2br($desc_array[$i])=="<br />" || nl2br($desc_array[$i])=="<br/>"){
$i++;
}
I checked my SQL file and the line breaks appear as
I have tried to check for this format too like
$desc_array[$i])=="
"
$desc_array[$i])=="
"
$desc_array[$i])=="
"
$desc_array[$i])==""
but still line break gets printed in description tag. Any ideas?