3v4l.org

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

preferences:
86.13 ms | 2633 KiB | 5 Q