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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| <?php
if ($rs['photo'] !== '') {
echo '<img src="img/articles/' . $rs['photo'] . '" style="width:200px;float:left;margin:5px;margin-left:-5px;cursor:pointer;" data-toggle="modal" data-target="#photo' . $r['id'] . '">';
}
preg_match_all('#<p(.*)</p>#isU', stripslashes(utf8_encode($rs['msg'])), $paragraphe);
$i = 0;
$affiche_txt_modif = 0;
$lemessage2 = stripslashes(utf8_encode($rs['msg']));
$lemessage = '';
$textComplet = '';
$found = [];
for ($i = 0; $i < count($paragraphe[0]); $i++) {
if (count($paragraphe[0]) > 1) {
//SI IL Y A + de 1 paragraphe
//SI LE PREMIER PARAGRAPHE EST MOIN DE 150 CARACTERES
if (strlen(strip_tags($paragraphe[0][0])) < 150) {
//'<div style="font-weight:bold;font-size:24px;">' . $paragraphe[0][0] . '</div>'
//'<div style="font-weight:bold;font-size:16px;">' . $paragraphe[0][1] . '</div>'
$bold = ' style="font-weight:bold;font-size:24px;"';
$lemessage = str_replace($paragraphe[0][0], '<div'.$bold.'>' . $paragraphe[0][0] . '</div>', $paragraphe[0][$i]);
$lemessage = str_replace($paragraphe[0][1], '<div'.$bold.'>' . $paragraphe[0][1] . '</div>', $lemessage);
$identifier = md5(trim($lemessage));
if(!in_array($identifier, $found)){
$found[] = $identifier;
}else{
$bold = '';
$lemessage = str_replace($bold, '', $lemessage);
}
$textComplet .= $lemessage;
$affiche_txt_modif = 1;
} else {
//SI LE PREMIER PARAGRAPHE A + DE 150 CARACTERES
// '<div style="font-weight:bold;font-size:16px;">' . $paragraphe[0][0] . '</div>'
$bold = ' style="font-weight:bold;font-size:24px;"';
$lemessage = str_replace($paragraphe[0][0], '<div'.$bold.'>' . $paragraphe[0][0] . '</div>', $paragraphe[0][$i]);
$identifier = md5(trim($lemessage));
if(!in_array($identifier, $found)){
$found[] = $identifier;
}else{
$bold = '';
$lemessage = str_replace($bold, '', $lemessage);
}
$affiche_txt_modif = 1;
$textComplet .= $lemessage;
}
} else {
//SI IL Y A 1 SEUL PARAGRAPHE
$lemessage = $paragraphe[0][$i];
$textComplet .= $lemessage;
$affiche_txt_modif = 1;
}
}
//ON AFFICHE LE TEXTE COMPLET
//echo "le text complèt est".$textComplet;
if ($affiche_txt_modif == 0) {
echo $lemessage2;
} else {
if (strlen($textComplet) > 950) {
echo '<div style="word-wrap: break-word;">';
echo substr($textComplet, 0, 950) . '... <a href="article.php?idarticle=' . $r['id'] . '">Lire la suite</a></p>';
echo '</div>';
} else {
echo '<div style="word-wrap: break-word;">';
echo stripslashes(utf8_encode($textComplet));
echo '</div>';
}
} |
Partager