string in 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
pedroz
Forum Commoner
Posts: 99
Joined: Thu Nov 03, 2005 6:21 am

string in array

Post by pedroz »

Code: Select all

$merchant_name = array (
	'Elizabeth Arden', 
	'InkPlusToner.com'
);
var_dump(in_array('Elizabeth Arden', $merchant_name));
// true, which is correct

$merchant_name_1 = array (
	'Elizabeth Arden' => 'Computers_and_Software', 
	'InkPlusToner.com' => 'Computers_and_Software'
);
var_dump(in_array('Elizabeth Arden', $merchant_name_1));
// false ...
How can I check for the array $merchant_name_1 if a string is in the array?

Thanks
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: string in array

Post by Celauran »

Code: Select all

var_dump(isset($merchant_name_1['Elizabeth Arden'));
Post Reply