/** * Format a book title (MLA) * * @param string $title * * @return string */ function formatBookTitle($title) { //Uppercase the words in book title $ret = ucwords($title); //Lowercase all articles, prepositions, & conjunctions $ret = Utility::lowerArticles($ret); //If the article title contains a subtitle, capitalize the first word after the colon if (preg_match('/:[ ]+[a-z]/', $ret, $matches)) { $ret = Utility::uppercaseSubtitle($ret); } //Punctuate after the book title, if necessary $ret = Utility::addPeriod($ret); return '<i>' . $ret . '</i>'; }
/** * Format a book title (APA) * * @param $title * * @return string */ function formatBookTitle($title) { //Uppercase the first word in article title $ret = ucfirst(strtolower($title)); //If the article title contains a subtitle, capitalize the first word after the colon $ret = Utility::uppercaseSubtitle($ret); //Punctuate after the book title, if necessary $ret = Utility::addPeriod($ret); $ret = '<i>' . $ret . '</i>'; return $ret; }