appending (s)printf output to string
I'm parsing some data and organizing it, and now I need to capture it inside a variable.
I've used printf in a manner like this to organize the data:
printf("%-30s %18s %18s\n", "$a", "$b", "$c\n");
Now I have a variable that's storing a string, and I want to append the organized data to the variable.
I tried something like $result.printf("%-30s %18s %18s\n", "$a", "$b", "$c\n");
and it doesn't work. I tried sprintf too.
I had to place the sprint statement in a variable first, like this:
$result = printf("%-30s %18s %18s\n", "$a", "$b", "$c\n");
And then concatenate the two variables like this:
$result .= $final_result;
That solved it.
sprintf is what you're needing.
|All times are GMT +1. The time now is 01:44 PM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.