比较来自不同来源的数组并按来源划分值

I have some difficulties to get some good idea how to divide values from arrays. For example I have 3 arrays of URLs:

$urlsFromA = ['http://www.test.com', 'http://www.example.com', 'http://www.google.com', 'http://www.twitter.com'];
$urlsFromB = ['https://www.test.com', 'http://www.example.com', 'http://www.bing.com'];
$urlsFromC = ['http://www.test.com', 'http://www.google.com'];

I need to foreach all of the arrays and get to other arrays values which I have duplicates in these start arrays and remove from start arrays if they occurred in the others. It is a little hindrance. Because URLs can be difference by 'https' for example but I must treat them like they are the same. So my result will be arrays with URLs named as a Source of this URLs:

$urlsFromABC = ['http://www.test.com'];
$urlsFromAB = ['http://www.example.com'];
$urlsFromAC = ['http://www.google.com'];
$urlsFromBC = [];

$dataFromA = ['http://www.twitter.com'];
$urlsFromB = ['http://www.bing.com'];
$urlsFromC = []; 

In $urlsFromABC I have URL which was in all arrays on start (despite the fact that it is different because of 'https'). In starting arrays ($dataFromA ,$urlsFromB, $urlsFromC) should be URLs that are not duplicated in other start arrays. Maybe someone have idea how can I do this?

First you need to create a function that changes https with http like this:

function replace($arr){
    foreach($arr as $key => $ar){
        $ar = str_replace('https', 'http', $ar);
        $arr[$key] = $ar;
    }
    return $arr;
}

You will call this function like this:

$urlsFromA = replace($urlsFromA);
$urlsFromB = replace($urlsFromB);
$urlsFromC = replace($urlsFromC);

After that you can play with this two functions: array_diff and array_intersect.

For example array_intersect:

$urlsFromABC = array_intersect($urlsFromA, $urlsFromB, $urlsFromC);

This will return all the values that exists in all the arrays. You can put how many arrays you want.

And array_diff:

$urlsFromA = array_diff($urlsFromA, $urlsFromB, $urlsFromC);

This will return the values that are in the first array and not in other. You can put how many arrays you want.

You can try how many cases you want. Hope it helps!