Created
January 2, 2018 12:29
-
-
Save mgsmus/44703f8aeee7759d6c15432e3e84f5ee to your computer and use it in GitHub Desktop.
Products variants
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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