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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.