3v4l.org

run code in 300+ PHP versions simultaneously
<?php $context = [ 'total_pedidos' => '211,10', 'valor_credito' => '31,80', 'valor_debito' => '49,90', 'valor_dinheiro' => '129,40' ]; foreach ($context as $key => $valor) { $valor = str_replace('.', '', $valor); $valor = str_replace(',', '.', $valor); $context[$key] = number_format($valor, 2) * 100; } $total = $context['total_pedidos'] - ($context['valor_credito'] + $context['valor_debito'] + $context['valor_dinheiro']); $total = $total / 100; var_dump($total);
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.29, 7.4.0 - 7.4.21, 8.0.0 - 8.0.8
float(0)

preferences:
364.7 ms | 459 KiB | 5 Q