3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php # This script will cater for any integer amount between 0 and 999999 $amount = 912904; $tmpAmount = 0; $tmpAmount2 = 0; $divident = 100000; $output = ""; while (($amount > 0) && ($divident > 0)) { if ($amount >= $divident) { $tmpAmount = (int)($amount / $divident); if (strlen($output) > 0) { $output .= "&"; } switch($tmpAmount) { case 1: { $output.="amount/one"; break; } case 2: { $output .= "amount/two"; break; } case 3: { $output .= "amount/three"; break; } case 4: { $output .= "amount/four"; break; } case 5: { $output .= "amount/five"; break; } case 6: { $output .= "amount/six"; break; } case 7: { $output .= "amount/seven"; break; } case 8: { $output .= "amount/eight"; break; } case 9: { $output .= "amount/nine"; break; } } switch($divident) { case 100000: case 100: { $output .= "&amount/hundred"; $output .= "&amount/and"; $tmpAmount2 = substr(($amount - ($divident * $tmpAmount)), 0, 1) * 10; switch($tmpAmount2) { case 10: { $tmpAmount2 = substr(($amount - ($divident * $tmpAmount)), 0, 2); switch($tmpAmount2) { case 11: { $output.="&amount/eleven"; break; } case 12: { $output .= "&amount/twelve"; break; } case 13: { $output .= "&amount/thir"."&amount/teen"; break; } case 14: { $output .= "&amount/four"."&amount/teen"; break; } case 15: { $output .= "&amount/fif"."&amount/teen"; break; } case 16: { $output .= "&amount/six"."&amount/teen"; break; } case 17: { $output .= "&amount/seven"."&amount/teen"; break; } case 18: { $output .= "&amount/eight"."&amount/teen"; break; } case 19: { $output .= "&amount/nine"."&amount/teen"; break; } } if ($divident == 100000) { $output .= "&amount/thousand"; } $amount = (int)substr($amount, 1, strlen($amount)); $divident = ($divident / 10); break; } case 20: { $output .= "&amount/twenty"; break; } case 30: { $output .= "&amount/thirty"; break; } case 40: { $output .= "&amount/fourty"; break; } case 50: { $output .= "&amount/fifty"; break; } case 60: { $output .= "&amount/sixty"; break; } case 70: { $output .= "&amount/seventy"; break; } case 80: { $output .= "&amount/eighty"; break; } case 90: { $output .= "&amount/ninety"; break; } } $amount = (int)substr($amount, 1, strlen($amount)); $divident = ($divident / 10); break; } #case 10000: #{ # $output .= "&amount/nine"; # break; #} case 1000: { $output .= "&amount/thousand"; break; } #case 100: #{ # $output .= "&amount/hundred"; # $output .= "&amount/and"; # break; #} case 10: { #TODO break; } } } $amount = (int)substr($amount, 1, strlen($amount)); $divident = ($divident / 10); } echo $output; ?>
based on B17W4
Output for 4.3.0 - 7.2.0
amount/nine&amount/hundred&amount/and&amount/twelve&amount/thousand&amount/nine&amount/hundred&amount/and&amount/fourty