PHP Classes
elePHPant
Icontem

number convert to words: my code in php is not working.

Recommend this page to a friend!
  All requests RSS feed  >  number convert to words  >  Request new recommendation  >  A request is featured when there is no good recommended package on the site when it is posted. Featured requests  >  No recommendations No recommendations  

number convert to words

Edit

by Angelene Jamias - 12 hours ago (2017-06-23)

my code in php is not working.

This request is clear and relevant.
This request is not clear or is not relevant.

+1

this is my code for the amount in words there's an error in my code. function numberTowords($num) { $ones = array(

1 => "one", 2 => "two", 3 => "three", 4 => "four", 5 => "five", 6 => "six", 7 => "seven", 8 => "eight", 9 => "nine", 10 => "ten", 11 => "eleven", 12 => "twelve", 13 => "thirteen", 14 => "fourteen", 15 => "fifteen", 16 => "sixteen", 17 => "seventeen", 18 => "eighteen", 19 => "nineteen", ); $tens = array( 2 => "twenty", 3 => "thirty", 4 => "forty", 5 => "fifty", 6 => "sixty", 7 => "seventy", 8 => "eighty", 9 => "ninety" , ); $hundreds = array( "hundred", "thousand", "million", "billion", "trillion", "quadrillion" , ); //limit t quadrillion @$num = number_format($num,2,".",","); $num_arr = explode(".",$num); @$wholenum = $num_arr[0]; @$decnum = $num_arr[1]; $whole_arr = array_reverse(explode(",",$wholenum)); krsort($whole_arr); $rettxt = ""; foreach($whole_arr as $key => $i){ if($i < 20){ @$rettxt .= $ones[$i]; }elseif($i < 100){ @$rettxt .= " ".$tens[substr($i,0,1)]; @$rettxt .= " ".$ones[substr($i,1,1)]; }else{ @$rettxt .= $ones[substr($i,0,1)]." ".$hundreds[0]; @$rettxt .= " ".$tens[substr($i,1,1)]; @$rettxt .= " ".$ones[substr($i,2,1)]; } if($key > 0){ @$rettxt .= " ".$hundreds[$key]." "; } } if($decnum > 0){ $rettxt .= " and "; if($decnum < 20){ $rettxt .= $ones[$decnum]; }elseif($decnum < 100){ $rettxt .= $tens[substr($decnum,0,1)]; $rettxt .= " ".$ones[substr($decnum,1,1)]." cents."; } } return $rettxt; }

Ask clarification

1 Recommendation

PHP Escrever Número Por Extenso: Spell numbers using words in Portuguese

This recommendation solves the problem.
This recommendation does not solve the problem.

0

by zinsou A.A.E.Moïse Reputation 1410 - 3 hours ago (2017-06-23) Comment

try this package to know how to improve your code... you can also try the package 1915 terbilang of Huda M Elmatsani to see how to improve your code...I may help you on your own code but i think that this part of PHPclasses site is above all for recommandations. I use futhermore this occasion to suggest a new functionality to the administrators of the site. A kind of general forum to ask questions about this type of matter...This could allow some clarity on the site and then make easier searching for user who are not programers...


Recommend package
: 
: