Bonjours, j'ai un fichier text et j'aimerais supprimer le contenu entre 2 indicateurs sans supprimer les indicateurs..
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 define('FICHIER', 'text.txt'); $fd = fopen(FICHIER,"r+"); if (!$fd) die("Impossible d'ouvrir le fichier"); $inc = FALSE; while (!feof($fd)) { $ligne = fgets($fd, 1024); if (!feof($fd)){ if (strpos($ligne,'###SEPARATOR###') > 1){ $inc = TRUE; } if (strpos($ligne,'###ENDSEPARATOR###') > 1){ $inc = FALSE; } if ($inc == TRUE){ $temp .= $ligne; //fwrite($fd,""); } } } echo $temp; fclose($fd); $fd = fopen(FICHIER,"w+"); fwrite($fd,$temp); fclose($fd);
Partager