Question : Finding the array id based on value of key.

Below is a sample array that I might pull from one of my radios, the goal is to find the array id based on a given mac-address.

For example using the following array, If the mac address being searched for is "00:00:00:00:00:EF" then I need to set a variable to "0" if it is "00:00:00:00:00:ED" then I need to set it to "1".

Hope that makes sense.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
Array
(
    [0] => Array
        (
            [.id] => *2
            [mac-address] => 00:00:00:00:00:EF
            [interface] => all
            [signal-range] => -120.120
            [authentication] => true
            [forwarding] => true
            [ap-tx-limit] => 0
            [client-tx-limit] => 0
            [private-algo] => none
            [private-key] => 
            [private-pre-shared-key] => 
            [management-protection-key] => 
            [disabled] => false
        )

    [1] => Array
        (
            [.id] => *1
            [mac-address] => 00:00:00:00:00:ED
            [interface] => all
            [signal-range] => -120.120
            [authentication] => false
            [forwarding] => true
            [ap-tx-limit] => 0
            [client-tx-limit] => 0
            [private-algo] => none
            [private-key] => 
            [private-pre-shared-key] => 
            [management-protection-key] => 
            [disabled] => false
        )

)


Thank you,
Clint

Answer : Finding the array id based on value of key.

You might use a foreach iterator to walk the array of arrays.  You would look at something like this (untested code)
1:
2:
3:
4:
5:
6:
<?php
foreach ($main_array as $k => $sub_array)
{
    if ($sub_array[mac-address] == '00:00:00:00:00:ED') echo $k;

}
Random Solutions  
 
programming4us programming4us