Op zaterdag 8 juli 2017 01:00:15 CEST schreef Dave Howorth:
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?
Maybe PHP is just slow at catching up with a new C feature? Or something in the build chain is? (I have no idea how PHP actually implements things - I spit in its face, unfortunately).
http://php.net/manual/en/class.numberformatter.php -- Gertjan Lettink, a.k.a. Knurpht openSUSE Board Member openSUSE Forums Team -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org