Skip to content

Feature Request: Add Number Formatting for Indian Numbering System #18505

Closed as not planned
@johnson361

Description

@johnson361

Description

I would like to request a feature for PHP that adds support for the Indian numbering system, which is widely used in India and other South Asian countries. In this system, large numbers are formatted differently from the Western system. The formatting includes terms like lakhs (1,00,000) and crores (1,00,00,000).

For example, the number 1234567 should be formatted as 12,34,567 (instead of 1,234,567 in the Western system).

Motivation:
This feature will be particularly useful for developers in India and neighbouring countries who need to display numbers in a format that aligns with the Indian number system. Currently, PHP only supports the Western number formatting system, and there is no built-in function for Indian number formatting.

Proposed Solution:
New Function: Introduce a function like number_format_indian($number) that will format numbers according to the Indian numbering system.

Example:
number_format_indian(1234567); // Output: 12,34,567
Customizable: Allow users to customize the separator if necessary (e.g., for different locales).

Edge Cases: Handle special cases like numbers with decimals (e.g., 1234567.89 should become 12,34,567.89).

Example in Action:

echo number_format_indian(1234567);   // Outputs: 12,34,567
echo number_format_indian(987654321); // Outputs: 98,76,54,321

Alternatives:
We could also consider enhancing the existing number_format() function by adding an option for the Indian number format.

Impact:
Backward Compatibility: This feature will be optional and won't affect existing functionality.

Localization: It would make PHP more useful for applications targeting users in India and other South Asian countries.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions