Add comma in the php number

0

I would like to add a "," after the first two numbers. For example: 2098 - > 20.98; 20398 - > 20,398; 201 - > 20.1; Does anyone know how to do this in php?

    
asked by anonymous 29.06.2018 / 14:16

1 answer

2

You can do this:

echo preg_replace('/^(..)/', '$1,', '2098'); // 20,98

You can read more about preg_replace here .

And regular expressions here .

    
29.06.2018 / 14:21