This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.lpad = function(length, padString) { | |
var str = this; | |
if (padString == undefined) { | |
padString = ' '; | |
} | |
while (str.length < length) { | |
str = padString + str; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class NumberToWordConverter | |
{ | |
private $numbers = array( | |
'', 'ein', 'zwei', 'drei', 'vier', 'fünf', 'sech', | |
'sieb', 'acht', 'neun', 'zehn', 'elf', 'zwölf' | |
); | |
private $numbersSingle = array( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Minified, 411 Bytes, with umlauts | |
Run with `php -d display_errors=Off` to hide DEPRECATED errors on 5.3 | |
See OO-Version at <https://gist.github.com/750787> | |
<?function n($n,$a=0){$e=array(2=>'zwan','dreißig')+$d=split(':',':ein:zwei:drei:vier:fünf:sech:sieb:acht:neun:zehn:elf:zwölf');$t=$n%10;return$n<1000?($n<100?($n<20?($n<13?($d[$n].(($n-7)?(($n-1||$a)&&$n-6?'':'s'):'en')):$d[$t].'zehn'):n($t,1).($t?'und':'').$e[$n/10].(ceil($n/10)-4?'zig':'')):n((int)($n/100),1).'hundert'.n($n%100)):n((int)($n/1000),1).'tausend'.n($n%1000);}while($i<10000)echo n(++$i),"\n"; | |
# verbose (some slight changes for readability) | |
function n($n, $prefix=0) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Gender extends Enum | |
{ | |
protected static $enum = array( | |
'MALE' => array('male', 'm', 'Dear Mr.'), | |
'FEMALE' => array('female', 'f', 'Dear Ms.') | |
); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This class provides an enum-like type (as in Java) for PHP | |
* | |
* To create an enum, the enum has to extends this Enum class and defined | |
* a static protected array $enum with its entites. | |
* This array can be either a normal collection, e.g. | |
* | |
* <code> |
NewerOlder