<?php $text = "ышвгфращфзышвгарзщыфшварышгвар"; $temp=""; while(strlen($text) > 3) { $temp .= substr($text, 0, 3)."-"; $text = substr($text, 3); } echo $temp; ?>