galvin Posted January 25, 2011 Share Posted January 25, 2011 What is the PROPER way to clear out an array? I have an array getting created as part of a loop process, and for each loop, I want the array to be emptied and start from scratch? I googled it and see some ways but the people offering the solutions don't seem too sure of themselves, so I just want to know if there is one, widely accepted and proper/efficient way to do this? Quote Link to comment https://forums.phpfreaks.com/topic/225587-proper-way-to-clear-outflush-an-array/ Share on other sites More sharing options...
galvin Posted January 25, 2011 Author Share Posted January 25, 2011 looks like it's... unset($array); If that is not the best way, let me know. Otherwise, I'll go with it Thanks Quote Link to comment https://forums.phpfreaks.com/topic/225587-proper-way-to-clear-outflush-an-array/#findComment-1164827 Share on other sites More sharing options...
jcbones Posted January 25, 2011 Share Posted January 25, 2011 Or, at the start of each loop, just reset the array. $array = array(); Quote Link to comment https://forums.phpfreaks.com/topic/225587-proper-way-to-clear-outflush-an-array/#findComment-1164828 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.