Convert operation result to thousands in PHP

Asked

Viewed 21 times

0

Good afternoon. I cannot convert the result of my function to thousands, I have tried to convert with some native functions of PHP unsuccessful.

function CafeGenerator() {
    $data_inicial = "2019-02-10";
    $data_atual = date('Y-m-d');
    $valor_inicial = 19900;
    $valor_a_somar = 30; // add 30 xicaras de café a cada dia

    // faz a diferença entre as datas desejadas e converte para dias
    $diferencaentredatasemmilissegundos =strtotime($data_atual) - strtotime($data_inicial);
    $diferencaemdias = intval($diferencaentredatasemmilissegundos/86400);

    // efetua a soma desejada
    $valorfinal = $valor_inicial + ($diferencaemdias * $valor_a_somar);
    return $valorfinal;

}

IMPRIME: 28120

Preciso do resultado: 28.120
  • 2

    Among these native functions, you tried to number_format?

  • Number Format not tried floatval etc..

  • I got $valor_formatted = number_format($final value,0,',','.'); Our was trying the hardest thank you.

  • I remove the admin question?

  • If you can, you can close as a duplicate of https://answall.com/q/11301/5878

No answers

Browser other questions tagged

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