PHP: Replace string in TXT file
Posted by Em on 27 February, 2008
2 Comments
This item was filled under [ PHP ]
Ever wanted to search, replace string in TXT files? Use PEAR’s File_SearchReplace and it will do the task for you. You can get a copy of package from: http://pear.php.net/package/File_SearchReplace/
Its quite easy to use. Here is sample code from PEAR’s website:
<?php include 'File/SearchReplace.php' ; $files = array( "test1.txt", "test2.txt", "test3.txt" ) ; $ignoreline = array( "#", ":") ; $snr = new File_SearchReplace( "Yes", "No", $files, "/mail/", false, $ignoreline) ; $snr -> doSearch() ; ?>
Popularity: 804 views
2 Comments on “PHP: Replace string in TXT file”
$filearray = file(”filename.txt”);
Is perhaps easier.
thats for sure, man