3v4l.org

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

preferences:
48.99 ms | 402 KiB | 5 Q