clear array from values

All your question about php
Post Reply
mister_v
Posts: 188
Joined: Thu Mar 04, 2010 9:19 pm

clear array from values

Post by mister_v »

Hi,

have an array in PHP, and I want to clear all values.
Actually empty it. Like it is new.
chris
Site Admin
Posts: 194
Joined: Mon Jul 21, 2008 9:52 am

Re: clear array from values

Post 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)
mister_v
Posts: 188
Joined: Thu Mar 04, 2010 9:19 pm

Re: clear array from values

Post by mister_v »

Thanks, I'll test it
Post Reply