3v4l.org

run code in 500+ PHP versions simultaneously
<?php $yearwithdecimal = "1.2"; $months = 0; if($yearwithdecimal){ $parts = explode('.', $yearwithdecimal); $months = $parts[0]*12 + $parts[1] ?? 0; } echo $months;

preferences:
47.61 ms | 1123 KiB | 5 Q