dcole.ath.cx Posted March 26, 2006 Share Posted March 26, 2006 Can Somesone look over my code, it has errors and I can't find them. I think it has something to do with read dir <?php$file = fopen("C:/list.txt", "r");$filesize = filesize("C:/list.txt");$etext = fread($file, $filesize);fclose($file);$etext = explode("\n", $etext);for($i = 0; $i < sizeof($etext); $i ++){ $dir = opendir("$etext[$i]"); while(false != ($file = readdir($dir))) { if(($file != ".") and ($file != "..")) { if(is_dir("$etext[$i]/$file")) { $file3 = fopen("C:/list.txt", "r"); $filesize = filesize("C:/list.txt"); $ltext = fread($file3, $filesize); fclose($file3); $file4 = fopen("C:/list.txt", "w"); $filesize = filesize("C:/list.txt"); fwrite($ltext, "$etext[$i]/$file \r"); fclose($file4); } else { $file5 = fopen("$etext[$i]/$file", "r"); $filesize = filesize("$etext[$i]/$file"); $badcontent = fread($file5, $filesize); fclose($file5); $fixcontent = str_replace("hi", "hello", $badcontent); $file2 = fopen("$etext[$i]/$file", "w+"); $filesize = filesize("$etext[$i]/$file"); fwrite($ltext, "$fixcontent"); fclose($file2); } } }}?> Link to comment Share on other sites More sharing options...
Guest sundaravadivel Posted April 1, 2006 Share Posted April 1, 2006 Can Somesone look over my code, it has errors and I can't find them. I think it has something to do with read dir<?php$file = fopen("C:/list.txt", "r");$filesize = filesize("C:/list.txt");$etext = fread($file, $filesize);fclose($file);$etext = explode("\n", $etext);for($i = 0; $i < sizeof($etext); $i ++){ $dir = opendir("$etext[$i]"); while(false != ($file = readdir($dir))) { if(($file != ".") and ($file != "..")) { if(is_dir("$etext[$i]/$file")) { $file3 = fopen("C:/list.txt", "r"); $filesize = filesize("C:/list.txt"); $ltext = fread($file3, $filesize); fclose($file3); $file4 = fopen("C:/list.txt", "w"); $filesize = filesize("C:/list.txt"); fwrite($ltext, "$etext[$i]/$file \r"); fclose($file4); } else { $file5 = fopen("$etext[$i]/$file", "r"); $filesize = filesize("$etext[$i]/$file"); $badcontent = fread($file5, $filesize); fclose($file5); $fixcontent = str_replace("hi", "hello", $badcontent); $file2 = fopen("$etext[$i]/$file", "w+"); $filesize = filesize("$etext[$i]/$file"); fwrite($ltext, "$fixcontent"); fclose($file2); } } }}?> <{POST_SNAPBACK}> you cannot do opendir and readdir for an array Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now