A simple string operation should be kept simple, so go with the most straight forward solution:
$str = substr($input, 0, 3).'-'.substr($input, 3, 3).'-'.substr($input, 6);
But as usually, there are several ways to skin a cat, so you have options. Like:
$str = sprintf('%s-%s-%s', substr($input, 0, 3), substr($input, 3, 3), substr($input, 6));
Or alternatively
$str = preg_replace('/^(.{3})(.{3})(.*)$/', '\1-\2-\3', $input);
Or alternatively
$str = preg_split('//', $input);
if (5 > count($chrs)) {
array_splice($chrs, 4, 0, '-');
}
if (3 > count($chrs)) {
array_splice($chrs, 2, 0, '-');
}
$str = implode('', $chrs);