Alright...

What I'm trying to do is get a list of all .PHP, .HTM and .HTML files in a
directory (recursively) and substitute a specific string from every file (if
the string exists).  The code I'm using follows.  It doesn't work.  When I
put it into the array, it only stores 80 objects... not sure why... If I
just raw echo, I get closer to 200.  *shrug*  Also, when it gets the file,
it doesn't seem to be replacing the string.  I'm sure I'm being stupid about
how I'm doing this... If anyone can show me what to do, I'd be very
appreciative.  A lot of the code, BTW, is just debugging stuff...  *sigh*


Jesse Williams
System Administrator
DowNET VoIP Team
Electronic Data Systems







<---- Begin Snippet



<?

function get_HTML_HTM_PHP_List ($dirName) {

        $arrayPath = array();
        $arrayFile = array();
        $d = dir($dirName);
        while($entry = $d->read()) {
                if ($entry != "." && $entry != "..") {
                        if (ereg(".html$", $entry) || ereg(".htm$", $entry) || 
ereg(".php$",
$entry)) {
                                //echo "d:/apache/htdocs/".$dirName."/".$entry."<br>";
                                $arrayPath = array($dirName);
                                $arrayFile = array($entry);
                        }
                        if (is_dir($dirName."/".$entry)) {
                                get_HTML_HTM_PHP_List($dirName."/".$entry);
                        }
                }
        }
        $d->close();

        //for ($i=0;$arrayFile[$i];$i++){print("$arrayFile[$i]<br>");}

        $string_to_remove = "http://www.blah.net/blah";;

        $string_to_insert = "http://xepherys.yi.org/";;

        //echo "<h3>" . array_count_values($arrayFile) . "</h3>";

        $a = 0;

        for ($i=0;$arrayFile[$i];$i++)  {

                $fp = fopen("d:/apache/htdocs/$arrayPath[$i]/$arrayFile[$i]", "rw");
                echo "$fp";
                ereg_replace($string_to_remove, $string_to_insert, $fp);
                echo "  Opened d:/apache/htdocs/$arrayPath[$i]/$arrayFile[$i]<br>";
        }





        //return($arrayFile);
}

get_HTML_HTM_PHP_List(".");

//for ($i=0;$myArray2[$i];$i++){print("$myArray2[$i]<br>");}
?>



End Snippet  ---->


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to