Jump to content

Archived

This topic is now archived and is closed to further replies.

gerkintrigg

Line breaks in if statements

Recommended Posts

Hello
How do i check if a variable has a line break in an if statement? I've broken a database field (address) into variables for each line and i noticed that if I left the line blank (with only a line break in it) it acts all goofy...

Can anyone help?
I tried this:[code]<?php
if (($_REQUEST['e']==y)&&(($city=='')||(nl2br($city)=='<br />'))){
echo 'bgcolor="#FF9999"';
}
else{
echo'bgcolor="#FFFFFF"';
}
?>[/code]

Share this post


Link to post
Share on other sites
try
[code]
<?php
if (($_REQUEST['e'] == "y") && (($city == null) || ( nl2br( $city ) == "<br />"))){
echo "bgcolor=\"#FF9999\"";
} else {
echo "bgcolor=\"#FFFFFF\"";
}
?>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.