g_p_java Posted February 3, 2009 Share Posted February 3, 2009 Hello, is there any function in php that erases everything in an array? Or shall someone use a for loop in order to erase what's inside an array? Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/143627-how-to-erase-every-record-in-an-array/ Share on other sites More sharing options...
Snart Posted February 3, 2009 Share Posted February 3, 2009 Just redefine the array: $x = array("one", "two", "three"); $x = array(); //Clears the array Link to comment https://forums.phpfreaks.com/topic/143627-how-to-erase-every-record-in-an-array/#findComment-753594 Share on other sites More sharing options...
Boo-urns Posted February 3, 2009 Share Posted February 3, 2009 Or use unset($arrayName); That is probably the preferred method to use. Link to comment https://forums.phpfreaks.com/topic/143627-how-to-erase-every-record-in-an-array/#findComment-753629 Share on other sites More sharing options...
premiso Posted February 3, 2009 Share Posted February 3, 2009 Or use unset($arrayName); That is probably the preferred method to use. It depends, if he is going to re-use it, Snart's way is better, if he is not, your way is better. All scenario dependent Link to comment https://forums.phpfreaks.com/topic/143627-how-to-erase-every-record-in-an-array/#findComment-753677 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.