tarun Posted February 6, 2007 Share Posted February 6, 2007 Okay Heres My Code $friendList; $friendList["Lisa"] = "offline"; $friendList["Jack"] = "online"; $friendList["Ryan"] = "offline"; $friendList["Rachel"] = "offline"; $friendList["Grace"] = "online"; foreach( $friendList as $key => $value){ echo "Friend: $key, Status: $value"; } How Would I Add And Remove Friends? Thnx, Tarun Link to comment https://forums.phpfreaks.com/topic/37341-array-adding-and-removing/ Share on other sites More sharing options...
Balmung-San Posted February 6, 2007 Share Posted February 6, 2007 To remove: unset($friendList["namegoeshere"]); To add: $friendlist["namegoeshere"] = "status"; To remove dynamically: if(array_key_exists($name_to_remove, $friendList)) { unset($friendList[$name_to_remove]); } To add dynamically: $friendList[$name_to_remove] = "status"; You might also want to change $friendList; to $friendList = array(); Link to comment https://forums.phpfreaks.com/topic/37341-array-adding-and-removing/#findComment-178517 Share on other sites More sharing options...
tarun Posted February 6, 2007 Author Share Posted February 6, 2007 WoW! Thnx - All Your Help Was Greatly Appreciated Tarun Link to comment https://forums.phpfreaks.com/topic/37341-array-adding-and-removing/#findComment-178524 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.