Aug 4

Numbers are great, sure, but sometimes you need to spell them out … and if you think the possibility for that to happen is slim, invoices and checks for example need to have the ammount in both numbers and letters (in most countries).

That’s why a script to convert numbers to words (to spell numbers) can come in handy.


function number_to_words ($x)
{
     global $nwords;
     if(!is_numeric($x))
     {
         $w = '#';
     }else if(fmod($x, 1) != 0)
     {
         $w = '#';
     }else{
         if($x < 0)
         {
             $w = 'minus ';
             $x = -$x;
         }else{
             $w = '';
         }
         if($x < 21)
         {
             $w .= $nwords[$x];
         }else if($x < 100)
         {
             $w .= $nwords[10 * floor($x/10)];
             $r = fmod($x, 10);
             if($r > 0)
             {
                 $w .= ' '. $nwords[$r];
             }
         } else if($x < 1000)
         {
		
             	$w .= $nwords[floor($x/100)] .' hundred';
             $r = fmod($x, 100);
             if($r > 0)
             {
                 $w .= ' '. number_to_words($r);
             }
         } else if($x < 1000000)
         {
         	$w .= number_to_words(floor($x/1000)) .' thousand';
             $r = fmod($x, 1000);
             if($r > 0)
             {
                 $w .= ' ';
                 if($r < 100)
                 {
                     $w .= ' ';
                 }
                 $w .= number_to_words($r);
             }
         } else {
             $w .= number_to_words(floor($x/1000000)) .' million';
             $r = fmod($x, 1000000);
             if($r > 0)
             {
                 $w .= ' ';
                 if($r < 100)
                 {
                     $word .= ' ';
                 }
                 $w .= number_to_words($r);
             }
         }
     }
     return $w;
}

Download: numbers-words.zip (1 KB)

Demo

The zip file contains the source code to convert numbers to words in both English and Romanian (you never knew when you need 'em).

So ... enjoy!

Jul 20

You all know the default Apache directory listing .. and I bet most of you hate it. It does the job, sure, but it’s not exactly the most useful (or the best looking).

This is why you might want to use a more professional script if you want to show some files/directories.

1. phpFe – PHP File explorer

It might not be the best looking, but it sure does its job .. and quite well I might add. It also has an admin module with basic functions. This is pretty much the only script that also takes SEO into consideration.

Website: http://phpfe.vigge.net

Download: http://phpfe.vigge.net/#download

Demo: http://phpfe.vigge.net/phpFe/

Read the rest of this entry »