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! Quote 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 Quote 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. Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.