3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '#1Lorem Ipsum is simply dummy text#2printing and typesetting industry#0nothing#35That\'s a big one!'; echo preg_replace_callback( '/#(\d+)((?:(?!#\d).)+)/', fn($m) => sprintf( '<span class="%s">%s</span>', (new NumberFormatter("en", NumberFormatter::SPELLOUT))->format($m[1]), htmlentities($m[2]) ), $string );

preferences:
28.21 ms | 406 KiB | 5 Q