Anything is possible.
If you have a string that is eight characters in length and you want 4-2-2 then something like this (there are many ways) can be done :
<?php
$date = '20010108';
$date = ereg_replace("([0-9]{4})([0-9]{2})([0-9]{2})","\1-\2-\3", trim($date));
print $date; // prints 2001-01-08
?>
See how it works? There are basically three "groups" each within () that you match, each being a number [0-9] and next to that is the lengths in braces {}. Then a bit later those three groups are printed out in the format we choose, which is to put dashes between them. \1 for exampe is the first group of numbers, four characters in length.
There is a great tutorial that will expand this information here :
http://phpbuilder.com/columns/dario19990616.php3
Good luck!