HalfaBee;10888928 wrote:You could use preg_replace(), something like this
$t = "0903324643";
echo preg_replace( "/(.*)(\d{3,3})(\d{3,3})$/" , "$1 $2 $3" , $t );
HalfaBee, you don't need {3,3}, as this says minimum of 3, maximum of 3.. you can simply use {3} instead (must be and only be 3 occurances)..
$str = '0903324643';
$str = preg_replace('#(\d*)(\d{3})(\d{3})$#' , '$1 $2 $3' , $str);