I have numbers in the database that are in full format. Ex: 12345
I want to convert it to the price format, in Reais. Ex: 12.345,00
I have numbers in the database that are in full format. Ex: 12345
I want to convert it to the price format, in Reais. Ex: 12.345,00
To return the value formatted in MySQL, do the following:
SELECT CONCAT('R$ ', FORMAT(valor, 2));
If you want to edit the value in PHP, you should use the number_format
function.
<?php
$valor = 12345;
$preco = 'R$' . number_format($num, 2, ',', '.'); // R$ 12.345,00