Avatar of ggjones
ggjones
Flag for Afghanistan asked on

How to find a value in an array

$haystack = array($vpKey1, $vpKey2, $vpKey3); // NEED TO BE VARIABLES

$vpKey1 = "Water Heaters";

$vpKey2 = "Plumbing Supplies";

$vpKey3 = "Heating";

$needle = "Heating";

if (in_array($needle, $haystack)){ echo '<P>yes';}else { echo '<P>no';}

Open in new window


This always returns "NO". How can this be made to work??

many thanks,

GJ

PHP

Avatar of undefined
Last Comment
ggjones

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
owner66

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Derokorian

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ggjones

ASKER

Thanks for the feedback. You are of course correct... but it didn't solve my larger problem the way I had hoped, as described here:

https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_27239549.html

regards,

GJ
Your help has saved me hundreds of hours of internet surfing.
fblack61