Dave Howorth wrote:
On Fri, 07 Jul 2017 16:32:32 +0200 Per Jessen <per@computer.org> wrote:
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).
You do know that the thousands separator does depend on the locale being set to a specific value, right?
Yup. When we process this stuff, we use en_GB.utf8, fr_CH.utf8, it_CH.utf8 or de_CH.utf8.
Maybe PHP is just slow at catching up with a new C feature?
Is it new? Hmm, I see it in the printf man page on my openSUSE 10.3 system, it's not overly new.
Or something in the build chain is? (I have no idea how PHP actually implements things - I spit in its face, unfortunately).
In PHP, I have always thought these C library functions were more or less implemented as "adapt the arguments, call the C function", but that's clearly not always the case. I guess a quick glance at the source will explain. -- Per Jessen, Zürich (24.7°C) http://www.hostsuisse.com/ - virtual servers, made in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org