help how to check if a variable can be found inside an array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
x
Forum Newbie
Posts: 12
Joined: Wed Jun 08, 2005 11:31 pm

help how to check if a variable can be found inside an array

Post by x »

Code: Select all

if ($var1==$orient_array['border']['0'] || $orient_array['border']['1'])
i dont know why this code wont work, the array($orient_array[border])has values that spans from 1-19 but doing this kind of if statement results to true even if i change it to !=. can anyone help me? :oops:
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

use in_array

Code: Select all

if(in_array($somevaluetosearchinthearray, $arrayofvalues))
{
   //
} ELSE
{
  //
}
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
x
Forum Newbie
Posts: 12
Joined: Wed Jun 08, 2005 11:31 pm

Post by x »

it worked, thanks a bunch Master! im sorry if i had to post this simple question im just running out of time to fix this thing im doing. wont let it happen again!! :D
Post Reply