Skip to content
Advertisement

find repeating unknown value from different keys of subarrays in PHP

I have an Array like this. this is a connection log of some devices to Internet.

JavaScript

source IP: [src_ip] and destination IP: [dst_ip] based on Sending or Receiving connection states change their position. we don’t know current network state (sending/receiving) also we don’t know current IP of device. IP of device is fixed but sometimes it placed on [src_ip] sometimes in [dst_ip]

but we can see repeating and continuous occurrence of an IP in either in [src_ip] or [dst_ip] of all subarrays (rows) which show us the IP of communicating device. how can find IP of device in this array using PHP? ( most repeating IP in first 100 row for example)

we can not use IP Address range.

Advertisement

Answer

JavaScript

If device_id is irrelevant:

JavaScript

Output:

JavaScript

If device_id matters, first filter for it:

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement