I'm trying to figure out a way to pass either the name of a state or a territory code to an array of sales representatives and have the script return that person's ID. Here is a sample:
$sales_people = array(
'2' => array(
'states' => array('NY', 'NJ', 'CT', 'MA', 'VT', 'ME'),
'codes' => array('CA1', 'US7', 'UT9')
),
'5' => array(
'states' => array('FL', 'GA', 'SC', 'NC', 'TN'),
'codes' => array('VA4', 'VA8', 'VA3')
)
);
If $foo = 'VA4'
, how would I go about having the script return 5
? Similarly, if $foo = 'NJ'
, how would I have it return 2
?
I was thinking of using in_array(), but it would appear as though that doesn't work on multidimensional arrays.
Any insight would be very much appreciated.