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); } 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']); 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(); 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 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
Archived
This topic is now archived and is closed to further replies.