function premieres_lettres_sur($texte, $lettre) { //print_r($texte); $texte = sansle($texte); $texte = unicode2charset(utf_8_to_unicode($texte), 'iso-8859-1'); $a = "ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ"; $b = "AAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn"; $texte=strtr($texte, $a, $b); // on retire les accents $texte = strtr($texte, "\xA1\xAA\xBA\xBF\xC0\xC1\xC2\xC3\xC5\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD8\xD9\xDA\xDB\xDD\xE0\xE1\xE2\xE3\xE5\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF8\xF9\xFA\xFB\xFD\xFF", "!ao?AAAAACEEEEIIIIDNOOOOOUUUYaaaaaceeeeiiiidnooooouuuyy"); $texte = strtr($texte, array("\xC4"=>"Ae", "\xC6"=>"AE", "\xD6"=>"Oe", "\xDC"=>"Ue", "\xDE"=>"TH", "\xDF"=>"ss", "\xE4"=>"ae", "\xE6"=>"ae", "\xF6"=>"oe", "\xFC"=>"ue", "\xFE"=>"th")); //array des mots interdits à compléter $mots_interdits = array('guide','','Autres','autre',':','quot','sous','avec','sans','pour','etc','dans','general','autoconstruit','autoconstruire','autoconstruction','autoconstruites','autoconstruits','autoconstruite','Autoconstruction'); //print_r($mots_interdits); // liste des mots if ($mots = str_word_count($texte, 1, $a)) { // on stocke la 1ère lettre de chaque mot dans un tableau $lettres = array(); foreach($mots as $mot) { //print_r($mots); // on ne prend en compte que les mots d'au moins 4 octets if (iconv_strlen($mot) > 3 AND !in_array($mot,$mots_interdits)){ $lettres = array_merge($lettres, array(strtoupper(substr($mot,0,1)))); $lettres = str_replace($lettre, ''.$lettre.'', $lettres); //$texte = implode($lettres); //print_r($texte); } } if (count($lettres)) { //print_r($lettres); $texte = $lettres; print_r($texte); } } return $texte; }