Skip to content

Use NumberFormatter instead of legacy NumberFormat #17006

Open
@rickmacgillis

Description

@rickmacgillis

Description

The following code:

<?PHP
function nth(int $number) : ?string {
		$formatter = new \NumberFormatter('en_US', \NumberFormatter::ORDINAL);
		$formatted = $formatter->format($number);
		return $formatted === false ? null : $formatted;
}

echo nth(651959195189);
?>

Resulted in this output:

651,959,195,189rd

But I expected this output instead:

651,959,195,189th

PHP Version

PHP 8.3.6

Operating System

Linux Mint 22

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions