Skip to content

Instantly share code, notes, and snippets.

@mgsmus
Created January 2, 2018 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgsmus/44703f8aeee7759d6c15432e3e84f5ee to your computer and use it in GitHub Desktop.
Save mgsmus/44703f8aeee7759d6c15432e3e84f5ee to your computer and use it in GitHub Desktop.
Products variants
// https://stackoverflow.com/a/33259643
function get_combinations($arrays) {
$result = array(array());
foreach ($arrays as $property => $property_values) {
$tmp = array();
foreach ($result as $result_item) {
foreach ($property_values as $property_key => $property_value) {
$tmp[] = $result_item + array($property_key => $property_value);
}
}
$result = $tmp;
}
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment