Forum Moderators: coopster

Message Too Old, No Replies

Can you include an IF in a variable construct?

         

Bigjohn

2:06 pm on Mar 5, 2004 (gmt 0)

10+ Year Member



Hard to describe... is this syntax correct:

if ($customer['billsame']) {$saddr= 'Customer Name: '.$customer['fullname']."\n" . if ($customer['comp']!="") {'Company name: '.$customer['comp']."\n"}

I know that it's not complete (or closed) but can I do that? While I'm building a variable?

What I want is:
Customer Name : customer
(if there is no company name skip, or output company name)
Address 1: first address line
Address 2: second address line

and so on...

John

volatilegx

3:37 pm on Mar 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd do it like this:

if ($customer['billsame'])
{
$saddr= 'Customer Name: '.$customer['fullname']."\n";
if ($customer['comp']){
$saddr .= $customer['comp']."\n";
}
}