Limit the number of newlines in a string
A very short blog post this time. I often use the following short function to limit the number of breaks/newlines in comments that people can submit on a news article or other user input. You can easily limit the number of characters in a comment by using the PHP strlen function, but the comment can still use a lot of vertical space on your website if the user uses 5 breaks in his comment. See the function below to prevent this type of comments:
/**
* limitBreaks, prevents texts with a lot of enters/breaks after each other
*
* @param string $sText
* @param int $iAmount default 2, numbers of newlines that may occur after eachother
* @return string, cleaned up string with limited number of newlines
*/
function limitBreaks($sText, $iAmount=2)
{
return preg_replace("/[\r\n]{".($iAmount+1).",}\t*[\r\n]*/", str_repeat(PHP_EOL, $iAmount), $sText);
}
As you can see a simple but effective function.
cheapest buy androxal cheap from usa
buy androxal usa suppliers
purchase androxal low cost
16 Aug 25 at 6:11 pm
how to order enclomiphene cheap wholesale
how to order enclomiphene purchase from uk
enclomiphene shipped over night without a perscription
16 Aug 25 at 6:16 pm
buying rifaximin generic next day delivery
cheapest buy rifaximin canada online order
by rifaximin online for cod
17 Aug 25 at 3:10 am
overnight xifaxan ups cod
buy xifaxan cheap in canada
buy xifaxan generic cheap
17 Aug 25 at 3:17 am
get staxyn canadian sales
staxyn cheap overnight delivery
online order staxyn generic available in united states
17 Aug 25 at 4:44 am
order avodart price netherlands
cheap avodart united kingdom
how to order avodart purchase usa
17 Aug 25 at 4:44 am
discount dutasteride cheap next day delivery
online order dutasteride cheap no prescription
buy cheap dutasteride canadian sales
17 Aug 25 at 6:04 am
cheapest buy flexeril cyclobenzaprine generic discount
cheapest buy flexeril cyclobenzaprine purchase singapore
order flexeril cyclobenzaprine generic next day delivery
17 Aug 25 at 6:04 am
ordering gabapentin generic canada no prescription
gabapentin drug no perscription
buy gabapentin without a prescription online
17 Aug 25 at 6:58 am
No perscription fildena fedex delivery
ordering fildena generic medications
cheap fildena price london
17 Aug 25 at 7:10 am
kamagra super nejlepší ceny
obecný kamagra
kamagra online lékařů
17 Aug 25 at 8:01 am
pharmacie canadienne en ligne kamagra
pharmacie canadienne kamagra pas chère
medicament kamagra en france
17 Aug 25 at 8:35 am
itraconazole for sale canada
ordering itraconazole cost uk
purchase itraconazole buy online canada
18 Aug 25 at 3:26 am