Mouth
Well-known member
PHP:
<?php
// get title
$title = $this->get('title');
// strip multiple punctuations !!!
$title = preg_replace('/([?!.:,;])[?!.:,;\s]+/', '$1 ', $title);
// remove periods(.) from end of title
$title = rtrim($title, '.');
// if 50% or more of title is UPPERCASE, apply title case
if ( mb_strlen(mb_ereg_replace('![^A-Z]+!', '', $title)) > ( mb_strlen($title) / 2) )
$title = mb_convert_case($title, MB_CASE_TITLE, 'utf-8');
// set title
$this->set('title', $title);
?>
Last edited: