Jump to content

Recommended Posts

Anybody got any idea how to do this?

 

Essentially, I'm constructing a delete function for a link directory and was wondering how you'd delete a variable from an array.

 

The way I've had to do it is by running a foreach() loop, followed by an "if" statement to rewrite each variable of an array. The problem is blank lines keep slipping through and messing up the script's display.

 

I know the foreach/if routine will be required to identify the variable to be deleted, but does anyone know how I can directly delete a variable instead of just omitting it?

 

Another problem is the loop runs an unnecessary amount of times, casing the script to take longer to load.

For some reason my test with a pre-set array will work 100% fine on my localhost, but not on my server.

 

I've got PHP 5.2 installed on my server and resources say unset has worked since around PHP 4, so I don't get it.

 

Anyone know why this might be?

I've just cracked it.

 

I thought it was unset, but it was where I used str_replace to remove page breaks.

 

The stored variables I was using to compare to the variable I was looking to delete contained a line break because it was at the end of a string in a text file. I did a quick google and realised there were a couple of ways to declare a line break. I created an array with all of those in and str_replace'd the array in each string and it worked.

 

It also solved a two week problem of trying to parse my documents for any blank lines that may have slipped in.

 

I literally made that discovery two minutes after posting, so I do apologise if I've wasted time.

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.