note 128974 added to function.number-format

From: Date: Fri, 20 Oct 2023 16:12:27 +0000
Subject: note 128974 added to function.number-format
Groups: php.notes 
Request: Send a blank email to php-notes+get-220931@lists.php.net to get a copy of this message
India (~18% of the world's population), Pakistan (~3%), Bangladesh (~2%), Nepal, and Myanmar, have a different way to display large numbers: 10,23,45,678.20 The first thousand is "normal" but then there is a comma every TWO digits after that. Now look at the number_format() function. Do you see a way to control the placement and frequency of the commas? Or a mode option/switch to deal with displaying numbers for almost 1/4 of the total population on Earth? Neither do I. If you are developing an application for an international audience, the ICU-based Intl PHP extension might work fine for you. However, IBM's ICU library is a resource heavy library (because...IBM), isn't the fastest library on the planet (also normal for IBM), ICU formatters are somewhat unreliable/inconsistent (yup, still IBM), and the Intl extension isn't always available in PHP (this one's PHP). So there are many significant hurdles to overcome just to prepare a number for display using the Intl extension. In short, approximately 23% of the planet currently can't use this function for displaying large numbers and there isn't a good built-in *lightweight* alternative other than to roll your own solution that outright replaces this function. Formatting a number for display is an extremely common task. Disclaimer: This comment serves as a warning to others that this function isn't suitable for an international audience in its current state. This comment is not a question, bug report, or feature request. I'm simply commenting on the current state of affairs with this function. If someone opts to make changes/improvements, then great, but that's not the purpose here. ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.157.134 (proxied: 174.18.3.52) ---- Manual Page -- https://php.net/manual/en/function.number-format.php Edit -- https://main.php.net/note/edit/128974 Del: integrated -- https://main.php.net/note/delete/128974/integrated Del: useless -- https://main.php.net/note/delete/128974/useless Del: bad code -- https://main.php.net/note/delete/128974/bad+code Del: spam -- https://main.php.net/note/delete/128974/spam Del: non-english -- https://main.php.net/note/delete/128974/non-english Del: in docs -- https://main.php.net/note/delete/128974/in+docs Del: other reasons-- https://main.php.net/note/delete/128974 Reject -- https://main.php.net/note/reject/128974 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#220931) next »