<?php
$products = [1, 2, 3, 4, 5];
$vendors = ["Amazon", "Newegg", "##php"];
$combinations = [];
foreach ($vendors as $vendor) {
foreach ($products as $productID) {
$combinations[] = array('product' => $productID, 'vendor' => $vendor);
}
}
var_dump($combinations);
- Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.10, 7.2.0 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- array(15) {
[0]=>
array(2) {
["product"]=>
int(1)
["vendor"]=>
string(6) "Amazon"
}
[1]=>
array(2) {
["product"]=>
int(2)
["vendor"]=>
string(6) "Amazon"
}
[2]=>
array(2) {
["product"]=>
int(3)
["vendor"]=>
string(6) "Amazon"
}
[3]=>
array(2) {
["product"]=>
int(4)
["vendor"]=>
string(6) "Amazon"
}
[4]=>
array(2) {
["product"]=>
int(5)
["vendor"]=>
string(6) "Amazon"
}
[5]=>
array(2) {
["product"]=>
int(1)
["vendor"]=>
string(6) "Newegg"
}
[6]=>
array(2) {
["product"]=>
int(2)
["vendor"]=>
string(6) "Newegg"
}
[7]=>
array(2) {
["product"]=>
int(3)
["vendor"]=>
string(6) "Newegg"
}
[8]=>
array(2) {
["product"]=>
int(4)
["vendor"]=>
string(6) "Newegg"
}
[9]=>
array(2) {
["product"]=>
int(5)
["vendor"]=>
string(6) "Newegg"
}
[10]=>
array(2) {
["product"]=>
int(1)
["vendor"]=>
string(5) "##php"
}
[11]=>
array(2) {
["product"]=>
int(2)
["vendor"]=>
string(5) "##php"
}
[12]=>
array(2) {
["product"]=>
int(3)
["vendor"]=>
string(5) "##php"
}
[13]=>
array(2) {
["product"]=>
int(4)
["vendor"]=>
string(5) "##php"
}
[14]=>
array(2) {
["product"]=>
int(5)
["vendor"]=>
string(5) "##php"
}
}
- Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
- Parse error: syntax error, unexpected '[' in /in/RAM25 on line 3
Process exited with code 255. - Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
- Parse error: parse error, unexpected '[' in /in/RAM25 on line 3
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- Parse error: parse error in /in/RAM25 on line 3
Process exited with code 255.
preferences:
176.61 ms | 401 KiB | 354 Q