Avatar of ggjones
ggjonesFlag 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
ASKER CERTIFIED SOLUTION
Avatar of owner66
owner66

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
Avatar of Derokorian
Derokorian
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of ggjones
ggjones
Flag of Afghanistan image

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/questions/27239549/How-to-find-a-value-in-an-array-redux.html

regards,

GJ
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo