I have
Array
(
[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
count($power_trails)
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: https://www.php.net/manual/en/function.array-map.php
outer function: https://www.php.net/manual/en/function.array-count-values.php
1 Like
system
Closed
5
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.