3v4l.org

run code in 500+ PHP versions simultaneously
<?php $str="I am a string with several periods.period #1. period #2."; $strings = explode('.', $str); $titleCased = []; foreach($strings as $s){ $titleCased[] = ucfirst(trim($s)); } echo join(".", $titleCased);

preferences:
109.5 ms | 2018 KiB | 5 Q