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?

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.