meltingpoint Posted February 16, 2010 Share Posted February 16, 2010 $openedfile =fopen($myfile, "r"); // if(!$openedfile) { echo "File could not be opened- please notify the Web Administrator<br>"; exit; } // //--------------------If no errors the script continues and we open and lock the file--------------------- // if(flock($openedfile, LOCK_EX)) { // $hold[$record_count] = explode("|", trim(fgets($openedfile))); while(!feof($openedfile)) { $record_count++; $hold[$record_count] = explode("|", trim(fgets($openedfile))); } // // flock($openedfile, LOCK_UN); fclose($openedfile); } By running the script I create a multidimensional array where each line of the text file is an array with in one large array. So I would have an array $hold where $hold[1] or $hold[234] would represent a specific record from the text database. Lets say I want to remove $hold[56] form $hold. What would the best way to do that be? I can unset($hold[56]) -----but how would I then write the remaining arrays in $hold back to the text database? Quote Link to comment Share on other sites More sharing options...
Catfish Posted February 16, 2010 Share Posted February 16, 2010 open new file for writing use a foreach loop on the array write each value from the array to the file close the file. Quote Link to comment Share on other sites More sharing options...
meltingpoint Posted February 16, 2010 Author Share Posted February 16, 2010 Thanks very much. Works beautifully. 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.