tarun Posted February 7, 2007 Share Posted February 7, 2007 I Had Help With This Yesturday And Now I Need Some More This Is My Example Code $friendList = array(); $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 Change The Values (offline, online etc.)? Thnx, Tarun Link to comment https://forums.phpfreaks.com/topic/37478-array-how-to-change-values/ Share on other sites More sharing options...
Balmung-San Posted February 7, 2007 Share Posted February 7, 2007 And I'm back again to help you. w00t! It's pretty simple actually, just: $friendList["name_here"] = "status_here"; Dynamic: $friendList[$name_to_remove] = $some_status_var; Since you're doing all this array stuff, I suggest you take a look at the PHP Array Docs. Link to comment https://forums.phpfreaks.com/topic/37478-array-how-to-change-values/#findComment-179228 Share on other sites More sharing options...
tarun Posted February 7, 2007 Author Share Posted February 7, 2007 Thnx - AGAIN For Your Help And For The Link Tarun Link to comment https://forums.phpfreaks.com/topic/37478-array-how-to-change-values/#findComment-179232 Share on other sites More sharing options...
The Little Guy Posted February 7, 2007 Share Posted February 7, 2007 Like this: <?php $friendList = array(); $friendList["Lisa"] = "offline"; $friendList["Jack"] = "online"; $friendList["Ryan"] = "offline"; $friendList["Rachel"] = "offline"; $friendList["Grace"] = "online"; $friend = 'Lisa'; if(array_key_exists($friend,$friendList)){ $friendList[$friend] = 'Online'; } foreach( $friendList as $key => $value){ echo "Friend: $key, Status: $value <br>"; } ?> Link to comment https://forums.phpfreaks.com/topic/37478-array-how-to-change-values/#findComment-179273 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.