Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
<?php
$str='Tova e teksta asdasd adaste tekst';
$strex=explode(' ', $str);
foreach ($strex as $strr)
{
$count=substr_count($str, $strr);
if ($count > 1)
{
$word_array = preg_split('/[\s?:;,.]+/', $strr, -1, PREG_SPLIT_NO_EMPTY);
$unique_word_array = array_unique($word_array);
$unique_str = implode(' ',$unique_word_array);
$save=$unique_str;
echo $save; //Преработен стринг..
}
else
{
echo $str; //Ако няма повтарящи връща нормалният стринг..
}
}
?>
$content = "blablablablabla";
$string = "bla";
$num_repeat = substr_count($content,$string);
$search = str_repeat($string,$num_repeat);
str_replace($search,$string,$content)
d_badboy каза:Направих си по кратка версия, но ако има по добри предложения ще ги приема
Каде ги учите толкова сложни работи бреКод:$content = "blablablablabla"; $string = "bla"; $num_repeat = substr_count($content,$string); $search = str_repeat($string,$num_repeat); str_replace($search,$string,$content)![]()