bonjour à tous.
j'utilise içi une balise for pour mettre en mots clé les ingrédients notés dans un formulaire dans un champ "ingredients". ces ingrédients sont notés comme suit:
+ciboulette
+aubergine
+oeufs
.et je coupe à chaque + afin de les mettre en mot clé. le souci est avec la boucle for qui les note.
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
<?
//on compte içi le nombre d'ingredients, en prenant comme repère le + avant chacun 
$ingredients=explode ( '+' ,$_POST[ingrédients]);
$nombreingredients=count($ingredients);
 
$recette=str_replace( "\'","'", nl2br($_POST[recette]));
$titre=str_replace( "\'","'", $_POST['titre']);
$mauvais= array(" ","\'","é","è","â","à","ê","î","ô","û","ä","ë","ï","ö","ü","ÿ","Ä","Ë","Ï","Ö","Ü","Â","Ê","Î","Ô","Û");
$bon= array("-","'","e","e","a","a","e","i","o","u","a","e","i","o","u","y","A","E","I","O","U","A","E","I","O","U");
$titre2=str_replace($mauvais, $bon, $titre);
 
$code1='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>'.$_POST['titre'].'</title>
<meta name="keywords" content="'.
for ($i = 1; $i < count($ingredients) ; ++$i) {
    echo $ingredients[$i].",";
}.'">
</head>
<body>
';
$code2='	
</body>
</html>
';
 
 
 
$fp= fopen("$titre2.html", "wb"); fwrite($fp, $code1.$titre.'<br/>'.$recette.$code2); fclose($fp);
?>