3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "i want to convert this string to the following"; echo preg_replace_callback('/\b\w(?:\w{1,2}\b)?/', fn($m) => strtoupper($m[0]), $string);
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
I Want TO Convert This String TO THE Following

preferences:
68.02 ms | 406 KiB | 5 Q