dereferencing array with variable string key

I have an array of WellKnownMACs which has the MACs as a key and the device name as the value as follows:

$wellKnownMACs = array (
‘00:cd:00:12:00:00’ => ‘Wii’,
‘00:ab:16:34:00:00’ => ‘Gateway’,


When I vardump it, everything looks good.

vardump ($wellKnownMACs[’'00:cd:00:12:00:00"]); works, but

vardump ($wellKnownMACs[’$i’]); always returns NULL. Am I missing something obvious?

My application reads MACs from router log files and substitutes the device name for well known devices.

Figured it out. All the examples (manual included) just use static strings as the key (e.g., array[‘abc’]). I was doing array[’$a’] instead of just array[$a]. Sorry for such a lame post. Now if I only knew how to delete the post.

Sponsor our Newsletter | Privacy Policy | Terms of Service