Page 1 of 1

clear array from values

Posted: Sat Jun 27, 2015 7:09 pm
by mister_v
Hi,

have an array in PHP, and I want to clear all values.
Actually empty it. Like it is new.

Re: clear array from values

Posted: Sat Jun 27, 2015 7:31 pm
by chris
you can set it to null

Code: Select all

$foo = null;

or re-initialize it:

Code: Select all

 $foo = array();
Or if you don't need it anymore,
you can "destroy" it:

Code: Select all

unset($foo);
PHP will clean up its memory
(when it needs to. I don't think it does it immediately)

Re: clear array from values

Posted: Fri Aug 21, 2015 9:16 pm
by mister_v
Thanks, I'll test it