Promise.all(
URL.map(
(url) => fetch(url)
.then((response) => `${url} : ${response.status} ${response.statusText}`)
.catch((e) => `${url} : ${e.message}`),
),
)
.then(
(results) =>
alert(results.join("\n")),
);
var unresolved = URL.length;
var results = [];
for (i = 0; i < URL.length; i += 1) {
(function(i) {
var request = new XMLHttpRequest();
request.open("GET", URL[i]);
request.onreadystatechange = function (event) {
console.log(request);
if (request.readyState === 4) {
if (request.status === 200) {
results[i] = URL[i] + ' РАБОТАЕТ';
} else {
results[i] = URL[i] + ' НЕ РАБОТАЕТ';
}
unresolved -= 1;
console.log(unresolved);
if (unresolved === 0) {
alert(results.join("\n"));
}
}
}
request.send();
})(i);
}
$localKeys = array_column($arr1, 'product');
$remoteKeys = array_column($arr2, 'product');
$totalKeys = array_values(array_unique(array_merge($localKeys, $remoteKeys)));
$localLinks = array_combine(
$localKeys,
array_column($arr1, 'local_link')
);
$remoteLinks = array_combine(
$remoteKeys,
array_columns($arr2, 'remote_link')
);
$result = array_map(
fn($key) => [
'product' => $key,
'local_link' => $localLinks[$key] ?? null,
'remote_link' => $remoteLinks[$key] ?? null
]
);
WITH RECURSIVE `cte` (`id`, `parent_id`, `title`, `n`) AS (
SELECT `id`, `parent_id`, `title`, 0
FROM `table`
WHERE `id` = :categoryId
UNION
SELECT `t`.`id`, `t`.`parent_id`, `t`.`title`, `n`+1
FROM `cte`
JOIN `table` AS `t` ON `t`.`id` = `cte`.`parent_id`
)
SELECT `id`, `title`
FROM `cte`
ORDER BY `n` DESC
Остаётся только выбрать все строки из ответа и вывести их в цикле. //переопределяю массив новыми размерамиС чего вы сделали такой вывод? Это просто получение значения из массива a по индексам row и col.
a[row][col];
Как решить проблему?Изучить, как создавать массив динамически.
const arr1 = [
[ 432432, 23423, 123123, 54364346],
[ 756456, 2423423, 645654, 23423423],
[ 12354, 123123, 23423423, 1235765]
]
const arr3 = [ 12354, 5345, 53456346 ]
const arrResult = arr1
.flat(Infinity)
.filter(el => arr3.includes(el))
console.log(arrResult)
// Array [ 12354 ]
const arr1 = [
[ 432432, 23423, 123123, 54364346],
[ 756456, 2423423, 645654, 23423423],
[ 12354, 123123, 23423423, 1235765]
]
const arr3 = [ 12354, 5345, 53456346 ]
const arr1s = arr1.flat(Infinity)
arr1s.sort((a, b) => a - b)
const arr3s = arr3.slice()
arr3s.sort((a, b) => a - b)
const arrResult = []
for (let i = 0, let j = 0; i < arr1s.length, j < arr3s.length;) {
if (arr1s[i] === arr3s[j]) {
arrResult.push(arr1s[i])
i += 1
} else if (arr1s[i] < arr3s[j]) {
i += 1
} else {
j += 1
}
}
console.log(arrResult)
// Array [ 12354 ]