Re: [PHP] Avoiding blank lines in HTML when field is empty

From: Chris Shiflett (shiflett_at_php.net)
Date: 10/23/03


Date: Thu, 23 Oct 2003 11:41:49 -0700 (PDT)
To: Robb Kerr <rkerr@digitaliguana.com>, php-general@lists.php.net


--- Robb Kerr <rkerr@digitaliguana.com> wrote:
> Here's the problem. Some of the fields are empty (for instance
> 'Address') and the way my code is configured a blank line appears in
> the returned data when the field is empty. How do I change this code
> to add a conditional that only echos the field contents AND the <br>
> when the field is NOT empty?

if (!empty($foo))
{
     echo $foo . '<br />';
}

Hope that helps.

Chris

=====
My Blog
     http://shiflett.org/
HTTP Developer's Handbook
     http://httphandbook.org/
RAMP Training Courses
     http://www.nyphp.org/ramp



Relevant Pages