Counting a key in an array

I have
[0] => Array
[power_trail_id] => 24
[power_strip_id] => 1
[receptacle_id] => 4
[outlett_placement] => 1
[circuit_breaker_id] =>
[power_panel_id] =>
[pdu_id] =>
[network_standard_id] => 1


How do I co unt the number of times a key (pdu_id) appears ?
Should be 0
I have


But that count the # of arrays, can I target a key?

combine array_map (reducing each sub-item to its pdu_id) and array_count_values.

dang, thanks, someth ing like

array_map(array_count_values(//how do  take out pdu_id from $power_trails to create a new array))

count them after you’ve mapped the array. The map should take the subitems, and return just the value of the key you’re interested in.
inner function:
outer function:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.