jet8791 Posted November 6, 2006 Share Posted November 6, 2006 I have a script here that i been working on and i cant get it right yet. can anybody help me. what i want it to do is open a folder called "files" open every txt file in the folder and go the 5th "|" and set the value to "0".can anybody help me? here is the script[code] <?php $dirname = "./files"; $dh = opendir( $dirname ) or die("couldn't open directory"); while ( $file = readdir( $dh ) ) { if ($file != '.' && $file != '..' && $file != ".htaccess") { $fh=fopen("./files/" . $file ,"w"); foreach($fh as $fline) $fline = explode('|', fgets($fh)); fputs($fh,$fline[0]."|". $fline[1]."|". $fline[2]."|". $fline[3]."|". $fline[4]."|".($fline[5]=0)."|". $fline[6]."|". $fline[7]."|". $fline[8]."|\n"); } } fclose($fo); echo "ok!"; ?>[/code] Quote Link to comment Share on other sites More sharing options...
sasa Posted November 6, 2006 Share Posted November 6, 2006 try[code]<?php$dirname = "./files";$dh = opendir($dirname) or die("couldn't open directory");while ($file = readdir($dh)) { if ($file != '.' && $file != '..' && $file != ".htaccess") { $fcon=file("$dirname/$file"); $fh=fopen("$dirname/$file ", 'w'); foreach ($fcon as $fline) { $fline = explode('|', $fline); $fline[5]=0; $fline = implode('|', $fline); fputs($fh, $fline); } fclose($fh); }}echo "ok!";?>[/code] Quote Link to comment Share on other sites More sharing options...
jet8791 Posted November 6, 2006 Author Share Posted November 6, 2006 it works finaly i been trying to get this work for the longest time. thank you very much :). i needed this for my fileupload site. http://easyfileupload.com Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.