What does the script doing ?

1.2 - Removing http:// & https:// from the strings, to make it all the same format

1.3 - Extracting top level domain name

1.4 - Registering or incrementing the $domains array on the extracted top level domain name

2 - Filtering the array (0, null, false, empty strings, are removed, that's why I register domain name with 0 and not 1) to keep only the 'doubt' domains (the ones that are present more than one time in the array)

3 - Then getting the keys of the array (because the keys are the domain names)