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 75 76 77 78
| ?PHP
//===========1 lire le repertoire de PHP======================
$data = glob('originaux/index1.php');
$Php_Lignes = array();
$i = 0;
echo ("<html><body><p align=center>");
foreach( $data as $filename)
{
if (is_file($filename) )
{
$work = $filename;
$NewPhp=str_replace("originaux","destination",$work);
//============a chaque php le lire=================
$work = file($filename);
$NbrLig=count($work)-1;
//========pur un PHP on entre dans son texte=====
for($a=0;$a<=$NbrLig;$a++)
{
/* Changer un truc par exemple */
$work[$a]=str_replace("toto1","pierre",$work[$a]);
$work[$a]=str_replace("toto2","alain",$work[$a]);
}
// ============ecrire fichier resultat=======
$LeFichier=fopen($NewPhp,"w+");
for($b=0;$b<$NbrLig;$b++)
{
$LeTexte=$work[$b];
fputs($LeFichier,$LeTexte."");
}
fclose($LeFichier);
echo ("fichier ".$NewPhp." OK<br />");
// ==============fin d un fichier==========
}
}
echo ("<br /></p></body></html>");
?>
?PHP
//===========1 lire le repertoire de PHP======================
$data = glob('originaux/index2.php');
$Php_Lignes = array();
$i = 0;
echo ("<html><body><p align=center>");
foreach( $data as $filename)
{
if (is_file($filename) )
{
$work = $filename;
$NewPhp=str_replace("originaux","destination",$work);
//============a chaque php le lire=================
$work = file($filename);
$NbrLig=count($work)-1;
//========pur un PHP on entre dans son texte=====
for($a=0;$a<=$NbrLig;$a++)
{
/* Changer un truc par exemple */
$work[$a]=str_replace("toto1","sylvie",$work[$a]);
$work[$a]=str_replace("toto2","cecile",$work[$a]);
}
// ============ecrire fichier resultat=======
$LeFichier=fopen($NewPhp,"w+");
for($b=0;$b<$NbrLig;$b++)
{
$LeTexte=$work[$b];
fputs($LeFichier,$LeTexte."");
}
fclose($LeFichier);
echo ("fichier ".$NewPhp." OK<br />");
// ==============fin d un fichier==========
}
}
echo ("<br /></p></body></html>");
?> |
Partager