undertaker Posted March 6, 2011 Share Posted March 6, 2011 $data=array('user1'=>'pass1','user2'=>'pass2'); now i would like that echo prints out the user1 word. echo $data[?what here?]; Link to comment https://forums.phpfreaks.com/topic/229801-arrays-help/ Share on other sites More sharing options...
flolam Posted March 6, 2011 Share Posted March 6, 2011 echo $data["user1"]; Link to comment https://forums.phpfreaks.com/topic/229801-arrays-help/#findComment-1183674 Share on other sites More sharing options...
undertaker Posted March 6, 2011 Author Share Posted March 6, 2011 Yes, but that outputs the pass1. I would like the USER1 word. I have that user and pass info stored in array. And now i would like to print out you are logged in as: USER1 Thank you Link to comment https://forums.phpfreaks.com/topic/229801-arrays-help/#findComment-1183678 Share on other sites More sharing options...
flolam Posted March 6, 2011 Share Posted March 6, 2011 foreach (array_keys($data) as $k => $v) { if ($v == "pass1") { echo $k; } } Link to comment https://forums.phpfreaks.com/topic/229801-arrays-help/#findComment-1183682 Share on other sites More sharing options...
undertaker Posted March 6, 2011 Author Share Posted March 6, 2011 thank you very much for your help Link to comment https://forums.phpfreaks.com/topic/229801-arrays-help/#findComment-1183683 Share on other sites More sharing options...
Pikachu2000 Posted March 6, 2011 Share Posted March 6, 2011 If you're logging people in, it would make more sense to store this information in $_SESSION vars. Link to comment https://forums.phpfreaks.com/topic/229801-arrays-help/#findComment-1183684 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.