<?php
function strtotitlecase( $title ) {
$smallwords = array( 'the','a','to','and','an','or','nor','but','of','is','if','then','else','at','from','when','by','on','off','for','in','out','with','over','into' );
$words = explode( ' ', $title );
foreach ( $words as $key => $word ) {
if ( $key == 0 or !in_array( $word, $smallwords ) ) {
$words[ $key ] = ucwords( $word );
}
}
$newtitle = implode( ' ', $words );
return $newtitle;
}
echo strtotitlecase("this is a title of an article"); // This is a Title of an Article
?>