Please find below my array
Array (
[0] => Array (
[id] => 0
[country] => GB
[note] => [email protected]
[cost] =>
[company] => Aberdeen Debenhams
[address_1] =>
[address_2] => Trinity Centre
[city] =>
[state] =>
[postcode] => AB11 6BD
[phone] => 01224 578553
)
[1] => Array (
[id] => 1
[country] => GB
[note] =>
[cost] =>
[company] => Basildon Debenhams
[address_1] =>
[address_2] => The Eastgate Centre
[city] =>
[state] =>
[postcode] => SS14 1HR
[phone] => 01268 244456
)
)
The array is stored in the DB as a serialized array as a single WordPress Option.
I have a string:
$storename = 'Aberdeen Debenhams';
I have a function I use to search multidimensional arrays for a string.
if(search_array($storename, $option)) {
echo 'true';
}
Now this rings true which is fine. The $storename is dynamic and comes from a previous function. What I need to do is be able to get the value of the [note] key within the same array so I can take that onto my next function.
UPDATE: In order for my next function to work I am using the following code to get the email address (key->note) from the same array as the $storename
//Get the email address of the storename
$key = array_search($storename, array_column($option,'company'));
echo $option[$key]['note'];
However, I am now getting the following.
Storename: Aberdeen Debenhams Email: [email protected]
Storename: Basildon Debenhams Email: [email protected]
It seems to be echoing the email address from the first array only.