I have a multidimensional PHP array looking like that:
[14]=>
array(2) {
[0]=>
int(29)
[1]=>
int(129)
}
[193]=>
array(3) {
[0]=>
int(6009231)
[1]=>
int(6324415)
[2]=>
int(5682922)
}
EDIT: there can be more than 2 keys (here 14 and 193). There can be n keys.
My goal is to get the following strings in a new array:
14:29;193:6009231
14:29;193:6324415
14:29;193:5682922
14:129;193:6009231
14:129;193:6324415
14:129;193:5682922
The conditions are that the key, values are separated by : and the elements are separated by ;
The first element should always be the first key (14) then we go through the values of this first key. The second element is always the second key, and again we go through the values of the second element.
EDIT: the keys are always sorted ascending
I manage to get all possible combinations key:values in the desired format as follow:
$properties_values_combinations = []
foreach ($myarray as $property) {
foreach ($property as $value) {
$properties_values_combinations[] = (string)$property.":".(string)$value;
}
}
However how can I combine elements of this array according to the result I want to achieve ?