J'ai un problème pour raccourcir mon code :
Code : Tout sélectionner
if ($titre[0] == "a" or $titre[0] == "A")
$tableau_A[] = $titre;
if ($titre[0] == "b" or $titre[0] == "B")
$tableau_B[] = $titre;
if ($titre[0] == "c" or $titre[0] == "C")
$tableau_C[] = $titre;
if ($titre[0] == "d" or $titre[0] == "D")
$tableau_D[] = $titre;
if ($titre[0] == "e" or $titre[0] == "E")
$tableau_E[] = $titre;
if ($titre[0] == "f" or $titre[0] == "F")
$tableau_F[] = $titre;
if ($titre[0] == "g" or $titre[0] == "G")
$tableau_G[] = $titre;J'ai essayer mais sans succes :
Code : Tout sélectionner
for($i='A'; $i<='Z'; $i++)
{
if ($titre[0] == $i)
$tableau_$i[] = $titre;
}
Code : Tout sélectionner
$tableau_A[] = $titre;
$tableau_B[] = $titre;
$tableau_C[] = $titre;
Merci pour vos réponse et j’espère avoir était assez clair .