Answer the question
In order to leave comments, you need to log in
How to insert a word after a certain number of characters + before a space?
Actually here is the code:
$s = "Очень длинное пр едложение каждый раз разное поэтому привязки к определенным символам класс ам нет и не будет";
$str = str_replace (" ", "", $s);
$kol_bukv = strlen ($str);
if($kol_bukv > 30){
$add = '[spoler]';
$pos = 30; //в какую позицию исходно строки вставить добавочную стоку
$result = substr($s, 0, $pos).$add.substr($s, -$pos);
echo $result;
}else{
echo $s;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question