- substr_replace: documentation ( source)
- ceil: documentation ( source)
- count_chars: documentation ( source)
<?php
function split_title($str){
return substr_replace(' ', '<span>', ceil((count_chars($str, 1)[32] + 1)/2), 1) . '</span>';
}
echo split_title('This is a test!');