Bonjour,

Je souhaiterais, comme le nom l'indique, respecter un formatage de saisie de sorte à ce qu'on est :
'prénom : Jean Edouard'.

Avoir donc un prénom qui a pour première lettre de chaque mot une majuscule.

Jusqu'à içi tout va bien cependant je tolère les chaines de caractères disposant de guillemets et d'apostrophe en début de chaines.

Du coup pour une chaine comme : 'éÉ'é-É'bé'
On a : 'Eé'E-E'Bé'

J'ai écris cette fonction :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
function first_char_MAJ($arg)
{
  //$new = utf8_decode($arg);
  $new = $arg;
  $new = str_split($new);
  $first_char=false;
  $indice_new=0;
    do{
      if(preg_match('#[a-zA-Z]#', $new[$indice_new]))
      {
        $new[$indice_new] = strtoupper($new[$indice_new]);
        $first_char=true;
      }
 
      if(preg_match('#à#', $new[$indice_new]))
      {
        preg_replace('#à#','A', $new[$indice_new]);
        $first_char=true;
      }
      if(preg_match('#â#', $new[$indice_new]))
      {
        preg_replace('#â#','A', $new[$indice_new]);
        $first_char=true;
      }
      if(preg_match('#ç#', $new[$indice_new]))
      {
        preg_replace('#ç#','C', $new[$indice_new]);
        $first_char=true;
      }
      if(preg_match('#è#', $new[$indice_new]))
      {
        echo'HEREEEEEEEEEE !';
        preg_replace('#è#','E', $new[$indice_new]);
        $first_char=true;
      }
      if(preg_match('#ê#', $new[$indice_new]))
      {
        echo'HEREEEEEEEEEE !';
        preg_replace('#ê#','E', $new[$indice_new]);
        $first_char=true;
      }
      if(preg_match('#é#', $new[$indice_new]))
      {
        echo'HEREEEEEEEEEE !';
        preg_replace('#é#','E', $new[$indice_new]);
        $first_char=true;
      }
      if(preg_match('#ë#', $new[$indice_new]))
      {
        echo'HEREEEEEEEEEE !';
        preg_replace('#ë#','E', $new[$indice_new]);
        $first_char=true;
      }
      if(preg_match('#ï#', $new[$indice_new]))
      {
        preg_replace('#ï#','I', $new[$indice_new]);
        $first_char=true;
      }
      if(preg_match('#î#', $new[$indice_new]))
      {
        preg_replace('#î#','I', $new[$indice_new]);
        $first_char=true;
      }
      if($indice_new == count($new)-1)
        $first_char=true;
 
      $indice_new++;
    } while ($first_char == false);
 
  $new = implode($new);
  // $new=utf8_encode($new);
  return $new;
}
Celle-ci fonction pour les lettres standard (a-z) mais dès que celles-ci ont des accents je rencontre un problème d'encodage.
Je ne vois pas du tout comment faire pour contrer ce problème si quelqu'un à une solution je suis preneur.

Merci d'avance