Adjust currency using PHP

Asked

Viewed 28 times

-1

I have the following value:

R$ 1,524.33

I need to write to the database in the format: 1524.33

How can I do that?

1 answer

1

Use the function str_replace:

<?
    $valor_sem_ponto = str_replace(',', '.', str_replace('.', '', "1.524,33"));
    echo $valor_sem_ponto;
?>

Upshot

1524.33

Browser other questions tagged

You are not signed in. Login or sign up in order to post.