Guardian-Mage Posted September 15, 2007 Share Posted September 15, 2007 ok, so $username = "Root". I need to check if the value of $username, in this case is in an array. $user[0] = "Root"; $pass[0] = "Root"; $admin[0] = $user[0]; $user[1] = "Cindy"; $pass[1] = "cindyloo"; $user[2] = "James"; $pass[2] = "simpsons"; $user[3] = "Geoff"; $pass[3] = "Icecream"; $user[4] = "Dawn"; $pass[4] = "furious"; $username = "Root"; In the case above, I need it to check to see if the username is in the user array, and in this case it is, with the value $user[0]. How can I check this? Do I use foreach or something? Link to comment https://forums.phpfreaks.com/topic/69497-solved-checking-if-a-value-is-in-an-array/ Share on other sites More sharing options...
ToonMariner Posted September 15, 2007 Share Posted September 15, 2007 $keynum = array_keys($user, 'Root'); if it is found you shoule return 0 (the index of that occurence in the array). Link to comment https://forums.phpfreaks.com/topic/69497-solved-checking-if-a-value-is-in-an-array/#findComment-349213 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.