3v4l.org

run code in 300+ PHP versions simultaneously
<?php function smart_uc_words($string) { $string = strtolower(trim($string)); // Capitalise any word char preceded by a non-word char other than an apostrophe $string = preg_replace_callback('/(?<!\w|\')(\w)/', function($m){ return strtoupper($m[1]); }, $string); // Capitalise any word char which comes between an apostrophe and another word char $string = preg_replace_callback('/(?<=\')(\w)(?=\w)/', function($m){ return strtoupper($m[1]); }, $string); return $string; } echo smart_uc_words("s'hertogengebosch");
Output for git.master, git.master_jit, rfc.property-hooks
S'Hertogengebosch

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.13 ms | 401 KiB | 8 Q