Empty an array?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Matt Phelps
Forum Commoner
Posts: 82
Joined: Fri Jun 14, 2002 2:05 pm

Empty an array?

Post by Matt Phelps »

Can't seem to find a function to do this. I want to empty an array completely of all data. I tried unset and empty but neither appear to work. Is there a way to empty an array?!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

//assuming you have a situation like:
$ar = array(1,2,3,4,5,6);
//empty it with:
$ar = array();
:D
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

to unset only one value of an array is:

Code: Select all

<?
unset($ar[0]);
?>
just wanted you to know it ;)
Post Reply