Knurpht - Gertjan Lettink wrote:
Op vrijdag 7 juli 2017 15:49:57 CEST schreef Per Jessen:
Knurpht - Gertjan Lettink wrote:
Op vrijdag 7 juli 2017 15:19:55 CEST schreef Knurpht - Gertjan
I can't see the input, but wouldn't number_format(printf("%.2f)") do the job?
That should have been number_format(printf("%.2f"))
Yes, I think it would, but what happens when the field-spec is a string or a hex format (for instance). Or when the format is "%'.2f".
You have to imagine a call like this:
dosomething( data, format );
'data' is whatever, 'format' is a printf() formatting specification.
That's what I have to deal with. I could write some concoction that would parse the input spec and use number_format() or printf(), but I would much prefer not having to parse that formatting spec.
Well, I did some more reading and only found that printf alone cannot do what you want to achieve.
Right. I was just curious if anyone happened to know why php's printf() doesn't support the thousands separator.
I've been struggling with this in the past where I had to deal with something like this (get data from one system into another). Never found another way then nestiing commands like described.
Except it only works when the pattern is known beforehand. I also wonder if number_format() takes the locale into account. (decimal pt and thousands separator). -- Per Jessen, Zürich (31.4°C) http://www.hostsuisse.com/ - dedicated server rental in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org