I don't believe trim would be a good choice for cleaning the title. This is best handled by a regular expression. For example:
$wordlist = array("the", "a", "an");
$string = "an animal in the house\n"; // example string
$pattern = "/^(" . join("|", $wordlist) . ") /i"; // build the pattern
echo preg_replace($pattern, "", $string);
The pattern used in this example is "/^(the|a|an) /i", which translates to "match beginning of string only, "the" or "a" or "an" followed by a space.
Delete the "an" and run it again. The "an" from the word "animal" is left intact as is the word "the" in the middle of the string.
I used an array to hold the word-list as it can easily be converted to a function that obtained the words from a user setting if this were some kind of plugin.