Bonjour, j'aurais besoin d'aide sur la création d'un script.

Je voudrais modifier un fichier .txt (un fichier .css pour être plus précis, mais ca ne change rien).

Voici le un exmple du fichier.
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
p.g-ouverture-g-o-doc-legende_gras {
	font-family: "Univers LT Std";
	line-height: 1.17em;
	font-size: 0.82em;
	margin-bottom: 0.00em;
	margin-top: 0.00em;
	text-indent: 0.00em;
	margin-right: 0.00em;
	margin-left: 0.00em;
	text-align: left;
	font-weight: normal;
	font-style: normal;
	color: rgb(0,0,0);
}
p.g-ouverture-g-o-chapitre {
	font-family: "Univers LT Std";
	line-height: 1.20em;
	font-size: 0.92em;
	margin-bottom: 0.00em;
	margin-top: 0.00em;
	text-indent: 0.00em;
	margin-right: 0.00em;
	margin-left: 0.00em;
	text-align: right;
	font-weight: normal;
	font-style: normal;
	color: rgb(255,230,0);
}
p.g-ouverture-g-o-titre-chapitre {
	font-family: "Oxtail OT";
	line-height: 0.92em;
	font-size: 4.33em;
	margin-bottom: 0.00em;
	margin-top: 0.00em;
	text-indent: 0.00em;
	margin-right: 0.00em;
	margin-left: 0.00em;
	text-align: left;
	font-weight: normal;
	font-style: normal;
	color: rgb(255,255,255);
}
Je suis entrain de créer un script qui fait les requêtes suivantes :
Si je trouve "font-family: "Univers LT Std";" je le remplace par "font-family:Verdana, Arial, Helvetica, sans-serif;".
Si je trouve "font-family: "Oxtail OT";je le remplace par "font-family:"Times New Roman", Times, serif;".

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
 
<?php
 
$ouvre=fopen("template.css","r"); 
 
$tab_r = array('font-family: "Univers LT Std";');
$tab_s = array('font-family: "Oxtail OT";');
 
$tab_i = array('font-family:Verdana, Arial, Helvetica, sans-serif;');
$tab_j = array('font-family:"Times New Roman", Times, serif;');
 
 
$chaine_h = str_replace($tab_r, $tab_i, $ouvre);
$chaine_h = str_replace($tab_s, $tab_j, $ouvre);
 
fclose($ouvre);		
 
$ouvre=fopen("texte.css","w+");
fwrite($ouvre,$chaine_h);
fclose($ouvre);
 
 
 
?>
Ce script ne fonctionne pas...

Merci de votre aide!

PS: j'aurais une requête supplémentaire facultative : si je trouve "p.g-ouverture-g-o-doc-legende_gras{" alors le font-weight passe de "normal" à "bold". Est-ce possible?