Jump to content

[SOLVED] checking if a value is in an array


Guardian-Mage

Recommended Posts

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.