3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo preg_replace_callback( '~(^\pL+\b)|(\b\p{Lu}+\b)~u', function($m) { return $m[1] ? mb_convert_case($m[1], MB_CASE_TITLE, 'UTF-8') : mb_strtolower($m[2], 'UTF-8'); }, 'THIS IS A Sentence that should be TAKEN Care of' );

preferences:
24.8 ms | 406 KiB | 5 Q