I am trying to write a script that will replace a string in a file. Actually, about 3000 files. And I am stuck. I can get the list of files, but then I pretty much become stuck. I wanted to try str_ireplace (not sure if that is what I should use or not), but I can't even get far enough to do that. I am hoping that someone out there has an easy response to this. Below is the code that I have so far.
Thanks
Steve
#!/usr/bin/php <? $strtoreplace="require \"http://www.domain.com/"; $replacewithstring="require \"/home/domain/www/";
replacestring();
function replacestring(){ GLOBAL $strtoreplace,$replacewithstring; $FILES=array(`ls -1 */*|grep .php`); foreach($FILES as $value){ if($value){ echo "file $value\n"; $handle=fopen($value,'a'); } } } ?>
^_^ You could use PEAR's File_SearchReplace. http://pear.php.net/package/File_SearchReplace
A few lines of code and it's all done for you. :-)
-- paperCrane <Justin Patrin>
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

