3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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(1)." >> "; echo getPatientCodeDisplay(1)." >> ";
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
AHD000001 >> AHD000001 >>