/**
* Получить произведение длинн массивов
* @param $array
* @return float|int
*/
function getProductOfSubArrCount($array) {
$arrayCount = [];
foreach ($array as $subArr) {
$arrayCount[] = count($subArr);
}
return array_product($arrayCount);
}
$numArr = count($array);
$numElems = count($array[0]);
$combinations = [];
$numCombinations = getProductOfSubArrCount($array);
for ($i = 0; $i < $numCombinations; $i++) {
$combination = [];
for ($j = 0; $j < $numArr; $j++) {
$arrIndex = $j;
$elIndex = $i / pow($numElems, $j) % $numElems;
$combination[] = $array[$arrIndex][$elIndex];
}
$combinations[] = $combination;
}
function foo($first, $second, $third) {
$pairs = [];
foreach ($first as $key => $item) {
foreach ($second as $s_item) {
foreach ($third as $value) {
$pairs[] = $item . ' -- ' . $s_item . ' -- ' . $value;
}
}
}
return $pairs;
}
$url = "https://www.jab.de/ru/ru/productsearch";
$cookie = "cookie.txt";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if (curl_errno($ch)) die(curl_error($ch));
phpQuery::newDocument($response);
$token = pq("meta[name=_csrf]")->attr('content');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
curl_setopt($ch, CURLOPT_POST, true);
$params = array(
'Content-Type: application/json; charset=UTF-8',
'pageSize' => 30,
'resultsNew' => 30,
'searchTerm' => 30,
'resultsDisplayed' => 30,
'sortCode' => "recommendation",
'CSRFToken' => $token,
'Accept' => 'application/json, text/javascript, */*; q=0.01',
'Accept-Encoding' => 'gzip, deflate, br',
'Accept-Language' => 'ru-RU,ru;q=0.9,en;q=0.8,en-GB;q=0.7,en-AU;q=0.6,en-US;q=0.5',
'Cache-Control' => 'no-cache',
'Connection' => 'keep-alive',
'Content-Length' => '7658',
'Host' => 'www.jab.de',
'Origin' => 'https://www.jab.de',
'Pragma' => 'no-cache',
);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
$html = curl_exec($ch);
if (curl_errno($ch)) print curl_error($ch);
var_dump($html);
curl_close($ch);
При замене на произведение длин массивов выдает некорректные результаты