<?php
$tests = [
'1,000.00',
'1,000.000',
'1.000,00',
'1.000,000',
'1.00',
'1.000',
'1,00',
'1,000',
];
var_export(
preg_replace(
['/[.,](?=\d*[.,])/', '/,/'],
['', '.'],
$tests
)
);
- Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
- array (
0 => '1000.00',
1 => '1000.000',
2 => '1000.00',
3 => '1000.000',
4 => '1.00',
5 => '1.000',
6 => '1.00',
7 => '1.000',
)
preferences:
49.83 ms | 402 KiB | 62 Q