I want to null or remove array at the end of each loop. I already tried unset() or $array=array(); but its not working

foreach($array as $key=>$value){
$dates[$value][]= $key;
unset($dates)
}

Just tell me php function to null all array

Your example makes little sense.

You want to unset $dates but I don't see it's definition. If you are trying to unset the array you are currently looping through, then you are asking for trouble.

Please be more specific in your code snippet with what and where you want to do this, so we know the whole scenario. Also, when you say you tried a few things, and it didn't work.. Let us know, why it didn't work: what happened?

Member Avatar for diafol

THat doesn't make much sense.

Have a look at array_shift

That returns the first item of an array as it removes it.

$arr = array('one','two','three');
$item = array_shift($arr);

will give

$item as 'one' and $arr as array('two','three')

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.