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; }
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.3.33, 7.4.0 - 7.4.25, 7.4.27 - 7.4.32, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
Two - 2 Eight - 8 Nine - 9 Eight - 8 Six - 6 Seven - 7 Nine - 9 Two - 2 Ninety-five trillion eight hundred ninety billion eight hundred fourteen million nine hundred eighty-four thousand one hundred forty-one - 95890814984141
Output for 8.0.13
Fatal error: Uncaught Error: Class "NumberFormatter" not found in /in/1mcaS:5 Stack trace: #0 {main} thrown in /in/1mcaS on line 5
Process exited with code 255.
Output for 7.3.32, 7.4.26, 7.4.33
Fatal error: Uncaught Error: Class 'NumberFormatter' not found in /in/1mcaS:5 Stack trace: #0 {main} thrown in /in/1mcaS on line 5
Process exited with code 255.

preferences:
78.64 ms | 408 KiB | 5 Q