Supprimer une chaine dans un fichier php
zamouranou
-
zamouranou -
zamouranou -
Bonjour,
svppp je veux supprimer juste une chaine mais tjr je trouve le fichier vide !!!
<?php
$fp = fopen ("vls.cfg", "r");
$texte=file_get_contents("vls.cfg");
$texte=str_replace($chaine ,'',$texte);
$fp = fopen ("vls.cfg", "w+");
fclose ($fp);
?>
svppp je veux supprimer juste une chaine mais tjr je trouve le fichier vide !!!
<?php
$fp = fopen ("vls.cfg", "r");
$texte=file_get_contents("vls.cfg");
$texte=str_replace($chaine ,'',$texte);
$fp = fopen ("vls.cfg", "w+");
fclose ($fp);
?>
A voir également:
- Supprimer une chaine dans un fichier php
- Supprimer rond bleu whatsapp - Guide
- Fichier bin - Guide
- Impossible de supprimer un fichier - Guide
- Comment réduire la taille d'un fichier - Guide
- Comment ouvrir un fichier epub ? - Guide
2 réponses
Cela fonctionnera mieux comme ceci:
Gates gave ^H sold you the windows.
GNU gave us the whole house.(Alexandrin)
johand@osiris: johand@osiris: ~/src/CCM/php $ cat vls.cfg kdgfnboljb fighn BLAH12345BLAH jbdsvjcfjfenvjfdevhnrevjhnb àçç!èèBLAH johand@osiris: ~/src/CCM/php $ cat text.php <?php $chaine="BLAH"; $file="vls.cfg"; $texte = file_get_contents($file); $texte = str_replace($chaine ,'',$texte); $fp = fopen($file, "w") or die("Could not open $file"); fwrite($fp, $texte); fclose ($fp); ?> johand@osiris: ~/src/CCM/php $ php text.php johand@osiris: ~/src/CCM/php $ cat vls.cfg kdgfnboljb fighn 12345 jbdsvjcfjfenvjfdevhnrevjhnb àçç!èè
Gates gave ^H sold you the windows.
GNU gave us the whole house.(Alexandrin)
ca marche pas pour moi !! j'ai des erreur au niveau code et aussi je détecte que le fichier a eu des modification et ops l'orsque j'ouvre le fichier rien n'est changé
voici la chaine que je veux la supprimé
BEGIN"223"
Name = "test5"
FileName = "/home/flux/SD/hd_h264_1.ts"
# Type = "Mpeg2-TS"
END
BEGIN "Channels"
out223 = "network"
END
BEGIN "out223"
DstHost = "225.22.15.19"
DstPort = "5001"
TTL = "2"
Type = "multicast"
END
BEGIN "LaunchOnStartUp"
#flux223 = "start test5 out223 local1 --loop"
END
#################################
voici la chaine que je veux la supprimé
BEGIN"223"
Name = "test5"
FileName = "/home/flux/SD/hd_h264_1.ts"
# Type = "Mpeg2-TS"
END
BEGIN "Channels"
out223 = "network"
END
BEGIN "out223"
DstHost = "225.22.15.19"
DstPort = "5001"
TTL = "2"
Type = "multicast"
END
BEGIN "LaunchOnStartUp"
#flux223 = "start test5 out223 local1 --loop"
END
#################################