3v4l.org

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

preferences:
24.73 ms | 404 KiB | 5 Q