3v4l.org

run code in 300+ PHP versions simultaneously
<?php function toCents($amount) { $cents = explode(',', $amount); if (!isset($cents[1])) $cents[1] = '00'; return (int) implode($cents); } $amount = '350.000,95'; echo toCents($amount); echo ' - '; $amount = '150'; echo toCents($amount);

preferences:
42.4 ms | 402 KiB | 5 Q