For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > May 2005 > Re: [PHP-DB] printf() in a variable, or alternative to printf()









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] printf() in a variable, or alternative to printf()
Philip Hallstrom

2005-05-27, 3:56 pm

> I need to be able to format data.
>
> Printf() is perfect because I need a certain amount of characters (30
> for address).
>
> However I need this formatted data to be inside a file that's fwrite()
> and then FTPed to a distributor who will parse it and input into their
> database.
>
>
> printf("% 4d",$orderID[0]); does not work in
>
> $thisContent="
>
> "data" .
> "moredate" .
> "evenmoredata" .
>
> ";
>
> In effect I need the output of printf() to be placed inside a variable
> and I don't see how to do that. Str_pad(), of course, does not work.
>
> Thx for any hints.


sprintf() is your friend!

http://us3.php.net/sprintf
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com