Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>bellow I am giving you an example function. It may not be a complete one but it should get you started (I know, the question has been posted long ago. still, it may help others - ) And I am sorry for any bugs :). and lastly, it is not finished one. I just post for an example starting point.</p> <pre><code>function convertToString($number, $blankIfZero=true){ $strRep = ""; $n = intval($number); $one2twenty = array("One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"); $twenty2ninty = array("Twenty", "Thirty", "Fourty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"); $hundred = "Hundred"; $thousand = "Thousand"; $million = "Million"; $billion = "Billion"; switch($n){ case 0: if($blankIfZero == true){ $strRep= $strRep.""; break; }else{ $strRep = $strRep."Zero"; break; } case $n &gt;0 &amp;&amp; $n &lt;20: $strRep = $strRep." ".$one2twenty[($n-1)]; break; case $n &gt;=20 &amp;&amp; $n &lt; 100: $strRep = $strRep . " ". $twenty2ninty[(($n/10) - 2)]; $strRep .= convertToString($n%10); break; case $n &gt;= 100 &amp;&amp; $n &lt;= 999: $strRep = $strRep.$one2twenty[(($n/100)-1)]." ".$hundred. " "; $strRep .= convertToString($n%100); break; case $n &gt;= 1000 &amp;&amp; $n &lt; 100000: if($n &lt; 20000){ $strRep = $strRep.$one2twenty[(($n/1000)-1)]." ".$thousand. " "; $strRep .= convertToString($n%1000); break; }else{ $strRep = $strRep . $twenty2ninty[(($n/10000) - 2)]; $strRep .= convertToString($n%10000); break; } case $n &gt;= 100000 &amp;&amp; $n &lt; 1000000: $strRep .= convertToString($n/1000). " ".$thousand. " "; $strRep .= convertToString(($n%100000)%1000); break; case $n &gt;= 1000000 &amp;&amp; $n &lt; 10000000: $strRep = $strRep . $one2twenty[(($n/1000000) - 1)]. " ".$million." "; $strRep .= convertToString($n%1000000); break; case $n &gt;= 10000000 &amp;&amp; $n &lt; 10000000000: $strRep .= convertToString($n/1000000). " ".$million. " "; $strRep .= convertToString(($n%1000000)); break; } return $strRep; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload