Since you're not using $str for anything else, you can just put the substr() function call directly into $user->lang() and save memory.