fork(1) download
  1. <?php
  2.  
  3. if(!function_exists('mb_ucfirst'))
  4. {
  5. function mb_ucfirst($string, $enc = 'UTF-8')
  6. {
  7. return mb_strtoupper(mb_substr($string, 0, 1, $enc), $enc) .
  8. mb_substr($string, 1, mb_strlen($string, $enc), $enc);
  9. }
  10. }
  11. function sentence_case($string) {
  12. $sentences = preg_split('/([.?!]+)/', $string, -1, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
  13. $new_string = '';
  14. foreach ($sentences as $key => $sentence) {
  15. $new_string .= ($key & 1) == 0?
  16. mb_ucfirst(strtolower(trim($sentence))) :
  17. $sentence.' ';
  18. }
  19. return trim($new_string);
  20. }
Success #stdin #stdout 0.02s 24412KB
stdin
Standard input is empty
stdout
Standard output is empty