3v4l.org

run code in 300+ PHP versions simultaneously
<?php $result2 = '{ "wg0": { "privateKey": "[hidden]", "publicKey": "XXXXXXXXXXXXXXXXXXX", "listenPort": 0, "peers": { "B3GtLuabWguXoG2Tz8KVukPXx3twn7A+X/SVT8=": { "endpoint": "0.0.0.0:5377", "latestHandshake": "Oct 28, 2020 1:58:32 UTC", "transferRx": "2.432 GB", "transferTx": "1.098 GB", "allowedIps": [ "10.85.85.2/32" ] }, "2Uqo3X2ubogU92LS4mWsZtF04ah3qJ4gt1g0=": { "endpoint": "0.0.0.0:5412", "latestHandshake": "Oct 28, 2020 1:58:52 UTC", "transferRx": "32.239 MB", "transferTx": "220.852 MB", "allowedIps": [ "10.85.85.3/32" ] } } } }'; $obj2 = json_decode($result2, true); $IPtoSearch = "10.85.85.2/32"; foreach ($obj2['wg0']['peers'] as $peer) { if (in_array($IPtoSearch, $peer['allowedIps'])) { $latestHandshake = $peer['latestHandshake']; break; } } echo "Last handshake for $IPtoSearch was at $latestHandshake\n";
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.29, 8.2.0 - 8.2.23, 8.3.0 - 8.3.11
Last handshake for 10.85.85.2/32 was at Oct 28, 2020 1:58:32 UTC

preferences:
77.62 ms | 407 KiB | 5 Q