$url[
['url'=>'http://example.com','id'=>1],
['url'=>'https://example.com','id'=>2],
['url'=>'https://url.com','id'=>3],
['url'=>'http://example.com','id'=>4],
['url'=>'http://big.com','id'=>5],
['url'=>'http://big.com','id'=>6],
['url'=>'http://data.com','id'=>7],
['url'=>'https://data.com','id'=>9],
['url'=>'https://shop.com','id'=>10],
['url'=>'https://shops.com','id'=>11],
];
$result = [
['url'=>'http://example.com','id'=>1],
['url'=>'http://example.com','id'=>4],
['url'=>'http://data.com','id'=>7],
];
<?php
$url = [
['url'=>'http://example.com','id'=>1],
['url'=>'https://example.com','id'=>2],
['url'=>'https://url.com','id'=>3],
['url'=>'http://example.com','id'=>4],
['url'=>'http://big.com','id'=>5],
['url'=>'http://big.com','id'=>6],
['url'=>'http://data.com','id'=>7],
['url'=>'https://data.com','id'=>9],
['url'=>'https://shop.com','id'=>10],
['url'=>'https://shops.com','id'=>11],
];
$http_urls = [];
$https_urls = [];
// Отделяем url-ы с https от http
foreach ($url as $item) {
if (preg_match('/^https/i', $item['url'])) {
$https_urls[] = stripProto($item['url']);
} else {
$http_urls[] = stripProto($item['url']);
}
}
// Находим одинаковые адреса в обоих массивах
$urls_itersect = array_intersect($http_urls, $https_urls);
// Оставляем в исходном массиве только url-ы с http, которые содержатся в массиве $urls_itersect
$url = array_filter($url, function($item) use ($urls_itersect) {
if (preg_match('/^http[^s]/i', $item['url']) && in_array(stripProto($item['url']), $urls_itersect)) {
return true;
} else {
return false;
}
});
print_r($url);
// Возвращает url без протокола
function stripProto($url) {
if (preg_match('/^https?(.+)$/i', $url, $m)) {
return $m[1];
}
}