3v4l.org

run code in 300+ PHP versions simultaneously
<?php // $a = array("1"=>2,"2"=>8,"3"=>9,"4"=>8,"5"=>6,"6"=>7,"7"=>9,"8"=>2); // used short array notation (see references) and removed keys (since not used) $numbers = [2,8,9,8,6,7,9,2,95890814984141]; // the last number is for my pleasure :P $numberFormatter = new NumberFormatter('en', NumberFormatter::SPELLOUT); foreach ($numbers as $number) { $numberSpelled = $numberFormatter->format($number); $numberSpelledWithFirstCharUpper = ucfirst($numberSpelled); echo $numberSpelledWithFirstCharUpper . ' - ' . $number . PHP_EOL; }

preferences:
23.19 ms | 404 KiB | 5 Q