Split string with characters in PHP. You can achieve this by taking a string $str, split it into chunks of 2 characters each with colons in between, and then remove any trailing colon from the resulting string. The final output will be a string with pairs of characters separated by colons.
Source code viewer
- $str = '12345';
- // Output: 12:34:5Programming Language: PHP