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:
21.78 ms | 474 KiB | 4 Q