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? Link to comment https://forums.phpfreaks.com/topic/192222-removing-one-array-from-a-multidimensional-array/ 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. Link to comment https://forums.phpfreaks.com/topic/192222-removing-one-array-from-a-multidimensional-array/#findComment-1012972 Share on other sites More sharing options...
meltingpoint Posted February 16, 2010 Author Share Posted February 16, 2010 Thanks very much. Works beautifully. Link to comment https://forums.phpfreaks.com/topic/192222-removing-one-array-from-a-multidimensional-array/#findComment-1012979 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.