Splitting text in PHP

php, regex, split, text

Solution

<?php
$i = '123456789';
echo 'result: ', wordwrap($i, 3, '-', true);

prints

result: 123-456-789

see http://php.net/wordwrap

Problem

I want to know is there any way to split text like this: 123456789 into 123-456-789 as to add "-" after every 3 characters? Just wanted to know, as I know the reverse, but how to do this is over my head. ;) and also if the text is ``` ABCDEFGHI OR A1B2C3D4E or any other format without any space between the characters ! ``` language: PHP only

Original source