i have a problem.i want to print mailing label using pdf.
if one the data is empty,i dont want to leave a blank like,like as below:
name
address1
address3
assume there is no data for address2,it will leave a blank space there.i dont want this to happen.i want to put something like this as below:
but it display error when i put the condition(if statement) inside the sprintf..how to put the condition inside?
PHP:
$pdf->Add_PDF_Label(sprintf("%s\n%s\n%s\n%s\n%s %s\n%s %s", "".ucwords($realname)."", "".ucwords($address1)."", "".ucwords($address2)."", "".ucwords($address3)."", "$postcode", "".ucwords($city)."", "".ucwords($state)."", "".strtoupper($country).""));
if one the data is empty,i dont want to leave a blank like,like as below:
name
address1
address3
assume there is no data for address2,it will leave a blank space there.i dont want this to happen.i want to put something like this as below:
PHP:
$pdf->Add_PDF_Label(sprintf("%s if(!empty($address1))\n%s if(!empty($address2)){\n%s}if(!empty($address3)){\n%s}if(!empty($postcode) or !empty($city)){\n%s %s}if(!empty($state) or !empty($country)){\n%s %s}", "".ucwords($realname)."", "".ucwords($address1)."", "".ucwords($address2)."", "".ucwords($address3)."", "$postcode", "".ucwords($city)."", "".ucwords($state)."", "".strtoupper($country).""));
but it display error when i put the condition(if statement) inside the sprintf..how to put the condition inside?