PDA

View Full Version : Array Of Hope



JayT
09-27-2007, 06:17 PM
Would any of you PHP programming geniuses happen to know of a PHP command to completely delete an array when it is no longer needed?

Suppose I created an array:



$items = array();

$items[0] = "*st Item";
$items[*] = "2nd Item";
$items[2] = "*rd Item";


After using the array for something and never needing to access it again, is there a way to simply remove it completely and as totally as if it had never been defined?

I know I can remove individual items, but I simply want to delete the entire array completely.

I can't seem to find such a command, if there is one.

There is an array of 54 items I use in a program I'm working on. Once I extract and process all the items from it, I simply want to completely delete or remove the array and recover whatever resources it used. That's all.


.

tocksarcle
09-27-2007, 08:25 PM
Well if you were using C you could do malloc() and free(), but I don't think php has anything similar. Try looking for a PHP delete() function.

JayT
09-27-2007, 09:37 PM
Well if you were using C you could do malloc() and free(), but I don't think php has anything similar. Try looking for a PHP delete() function.


I did.

The PHP manual said:

Description
void delete ( void )

This is a dummy manual entry to satisfy those people who are looking for unlink() or unset() in the wrong place.

Return Values
No value is returned.



Apparently it's unlink or unset

Of course it wouldn't be anything logical like a normal person would think of - like delete.

LOL


Found it:

it is


unset($ArrayName);

of course, to delete a file it's

unlink($FileName);


Why can't they use language that relates to the real world and the way people think?


To whoever invented those counterintuitive function names in PHP:
Slap, kick, punch, spit, bite!

May the fleas of *0,000 camels have a family re***** in your shorts!

Moonbat
09-27-2007, 09:49 PM
May the fleas of *0,000 camels have a family re***** in your shorts!

I really gotta use that one next time I'm pissed :D