1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
public static function anti_deforme($texte,$limit)
{
$le_texte = explode(" ", $texte);
$the_text = "";
for($compt = 0 ; $compt<=count($le_texte) ; $compt++) {
if (strlen($le_texte[$compt]) > $limit) {
$le_mot = substr($le_texte[$compt],0,$limit);
$le_mot_2 = substr($le_texte[$compt],$limit);
$the_text .= " ".$le_mot;
if (strlen($le_mot_2) > $limit) {
while (strlen($le_mot_2) > $limit) {
$le_mot_2_coupe = substr($le_mot_2,0,$limit);
$le_mot_2 = substr($le_mot_2,$limit);
$the_text .= " ".$le_mot_2_coupe;
if (strlen($le_mot_2) < $limit) {
$the_text .= " ".$le_mot_2;
}
}
} else {
$the_text .= " ".$le_mot_2;
}
} else {
$the_text .= " ".$le_texte[$compt];
}
}
return nl2br($the_text);
} |
Partager