
Knurpht - Gertjan Lettink wrote:
Op vrijdag 7 juli 2017 15:19:55 CEST schreef Knurpht - Gertjan Lettink:
Op vrijdag 7 juli 2017 13:14:35 CEST schreef Per Jessen:
Knurpht - Gertjan Lettink wrote:
Op vrijdag 7 juli 2017 11:51:33 CEST schreef Per Jessen:
Per Jessen wrote:
Does anyone know why PHP printf() does not (apparently) support the ' (single quote) to indicate a number format with thousands separator?
This is the printf() format (for instance): "%'.2f". This works fine in C and with bash:printf, but somehow not in php. I was just wondering why that might be?
No idea why, but I mostly use number_format(..), see http://php.net/manual/en/function.number-format.php
Yeah, that's my googling kept tellme too. That won't work though - the patterns are given to me as fields from a 3rd party. They have to work with printf(), that is the only limitation. When I call printf() in php, I expect(ed) it to work with all the patterns from from C. If I were to use number_format(), it won't work with "%.2f".
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. -- Per Jessen, Zürich (31.1°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