aeroswat Posted February 22, 2010 Share Posted February 22, 2010 I want it to unset that part of the array foreach($arr as $ar) { unset($ar); } Quote Link to comment https://forums.phpfreaks.com/topic/192963-will-this-do-what-i-expect-it-to/ Share on other sites More sharing options...
manohoo Posted February 22, 2010 Share Posted February 22, 2010 No. You have to specify the array index or key. For example: unset ($arr[0]); unset ($arr['name']); Quote Link to comment https://forums.phpfreaks.com/topic/192963-will-this-do-what-i-expect-it-to/#findComment-1016221 Share on other sites More sharing options...
ignace Posted February 22, 2010 Share Posted February 22, 2010 Your code should have been: foreach ($array as $key => $value) { unset($array[$key]); } But this is equal to the faster: $array = array(); Quote Link to comment https://forums.phpfreaks.com/topic/192963-will-this-do-what-i-expect-it-to/#findComment-1016232 Share on other sites More sharing options...
aeroswat Posted February 22, 2010 Author Share Posted February 22, 2010 thanks Quote Link to comment https://forums.phpfreaks.com/topic/192963-will-this-do-what-i-expect-it-to/#findComment-1016237 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.