View unanswered posts | View active topics It is currently Wed Aug 17, 2022 2:49 pm



Reply to topic  [ 2 posts ] 
 printing mailing label without blank line 
Author Message
Junior Member

Joined: Mon May 10, 2004 3:25 am
Posts: 1
Post 
i have a problem.i want to print mailing label using pdf.


[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).""));
[/php]

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).""));
[/php]


but it display error when i put the condition(if statement) inside the sprintf..how to put the condition inside?


Mon May 10, 2004 3:30 am
Report this post
Profile
Junior Member

Joined: Sat May 10, 2003 1:39 pm
Posts: 37
Post 
for 1 address line,

Code:
$address = sprintf("%s%s" ,
         $address1,
         empty($address1)?"":"\n" );

_________________
Barand


Sat May 15, 2004 4:24 pm
Report this post
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.