<?php $str = "2081180100100000072"; $str = preg_replace('/(\d{4})(?=\d)/', '$1 ', $str); echo "<br>"; echo $str; ?>