3v4l.org

run code in 300+ PHP versions simultaneously
<?php $usPhone = '123-456-7800'; $digits = sscanf($usPhone, '%1s%1s%1s-%1s%1s%1s-%2s%2s'); $f = new NumberFormatter('en', NumberFormatter::SPELLOUT); echo implode( ' ', array_map( fn($d) => ($d !== (string)(int)$d ? 'oh ' : '') . (!(int)$d ? 'oh' : $f->format((int)$d)), $digits ) );
Output for 8.5.1 - 8.5.3
Fatal error: Uncaught Error: Class "NumberFormatter" not found in /in/ZrRKX:7 Stack trace: #0 {main} thrown in /in/ZrRKX on line 7
Process exited with code 255.
Output for 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0
one two three four five six seventy-eight oh oh

preferences:
60.41 ms | 849 KiB | 4 Q