Are there any specific PHP functions or methods that are particularly useful for sorting and counting IP addresses?

When working with IP addresses in PHP, it can be useful to sort and count them for various purposes such as analyzing traffic patterns or identifying unique visitors. One way to achieve this is by using the `ip2long()` function to convert IP addresses to integers, which can then be easily sorted and counted using PHP's array functions like `sort()` and `array_count_values()`.

// Sample array of IP addresses
$ipAddresses = ['192.168.1.1', '192.168.1.2', '192.168.1.1', '192.168.1.3', '192.168.1.2'];

// Convert IP addresses to integers for sorting and counting
$ipIntegers = array_map('ip2long', $ipAddresses);

// Sort the IP addresses
sort($ipIntegers);

// Count the occurrences of each IP address
$ipCounts = array_count_values($ipIntegers);

// Display the sorted IP addresses and their counts
foreach ($ipCounts as $ipInteger => $count) {
    $ipAddress = long2ip($ipInteger);
    echo "$ipAddress: $count\n";
}