On 6/30/06, tedd <[EMAIL PROTECTED]> wrote:
At 11:07 PM -0600 6/29/06, John Meyer wrote:
>Larry Garfield wrote:
>>
>>switch is fine if your elseif comparisons are equality based.  If they're not 
equality based, then they don't map to switch as well.
>

Not true.  I've come to really appreciate the structure of switches.
What helps to "unlock" their power is that you don't *have* to compare
your switch() param with your case() params.

Building on Paul's good advice of splitting logic from presentation:


[code]

$display_name = '';

switch('set_display_name')
{
        case($row[1] == 'none'):
        case($row[1] == $row[2]):
                $display_name = $row[0] . ' ' . $row[2];
                break;
        
        default:
                $display_name = $row[0] . ' (' . $row[1] . ') ' . $row[2];
                break;
        
}

// now print table, using $display_name
[/code]

HTH,
John W

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to