I have some long simple text and i need to insert <span id='colorme'></span>
tag after first 5 sentences only once and after that i need to insert <p...></p>
tags after every 5 sentences till the end of the text. But if full text less than 5 sentences, the script must do nothing.
For example:
Without false modesty, we state that we have the best staff possible. And it's not some kind of farce, fiction or someone's evil joke. No, no - this is the most sincere truth. All our employees are incredibly welcoming, smiling, polite, tidy and competent in their work. Thanks to this, our sauna has been working successfully for many years, bringing pleasure to all its customers, both permanent and new. Come, we will be glad to see you. With respect to you, Alina.
And i need:
Without false modesty, we state that we have the best staff possible. And it's not some kind of farce, fiction or someone's evil joke. No, no - this is the most sincere truth. <span id='colorme'></span>
All our employees are incredibly welcoming, smiling, polite, tidy and competent in their work. Thanks to this, our sauna has been working successfully for many years, bringing pleasure to all its customers, both permanent and new. Come, we will be glad to see you. <p style='color:red'>www.example.com</p>
With respect to you, Alina.
It's just an example. So have something like this, it's not work property, just added <span>
after every 3 sentences but i need only once, i don't even know what must I do
<?php
$long_text = 'long long text';
$str = $long_text;
$arr = explode(".", $str);
$new_str = "";
$j = 1;
foreach($arr as $arr_el) {
$new_str .= $arr_el.".";
if($j % 3 == 0) {
$new_str .= "<span id=colorme></span>";
};
$j++;
}
echo $new_str;?>