3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getPatientCodeDisplay($id='') { if(intval($id)>0) { $id_length = strlen($id); $prefix_code = "AHD"; $final_len = 6+strlen($prefix_code)-$id_length; $retstr = str_pad($prefix_code, $final_len, "0", STR_PAD_RIGHT); $retstr .= $id; } else { $retstr = ""; } return $retstr; } echo getPatientCodeDisplay(12);

preferences:
41.31 ms | 402 KiB | 5 Q