To truncate a string to the first n characters and add three dots if any characters are removed in PHP, you can use the following function.