Jump to content

removing one array from a multidimensional array


meltingpoint

Recommended Posts

$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?

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.