rtrim the separator. Removes trailing colons only.
Keep mid separators. Joins between chunks stay intact.
Frequently Asked Questions
chunk_split() breaks a string into fixed-size pieces and inserts a separator after each piece. It returns one combined string—not an array. The last chunk may be shorter, and the separator is still appended after it.
string chunk_split(string $string, int $length = 76, string $separator = "\r\ "). Pass the input, the chunk size (default 76), and the separator after every chunk (default CRLF).
That is by design. Every chunk—including the final partial one—gets the separator. Trim it afterward, or use str_split() plus implode() if you need different joining rules.
chunk_split() returns one string with separators inserted. str_split() returns an array of chunks with no separator. Use chunk_split() for formatted output; use str_split() when you process chunks one by one.
76 characters per line is a common convention for email and MIME-encoded content. The default separator "\r\ " matches CRLF line endings used in many mail formats.