Answer the question
In order to leave comments, you need to log in
What "Hindu code" converts an array into a relational structure of arrays?
There is such an array - in other words - a product from the price list
$arr = array(
"param1" => "value",
"param2" => "value",
"param3" => array("value", "value2"),
"param4" => array("value", "value2"),
"param5" => "value",
"param6" => array("value", "value2"),
"param7" => "value",
"param8" => array("value", "value2"),
);
$param_enum = array();
foreach ($arr as $k => $v):
if (is_array($v)):
foreach ($v as $v2):
$param_enum[] = array(
"param" => $k,
"enum" => $v2
);
endforeach;
else:
$param_enum[] = array(
"param" => $k,
"enum" => $v
);
endif;
endforeach;
array(
0 => array(
"param" => "param1",
"enum" => "value"
),
1 => array(
"param" => "param2",
"enum" => "value"
),
2 => array(
"param" => "param3",
"enum" => "value"
),
3 => array(
"param" => "param3",
"enum" => "value2"
),
4 => array(
"param" => "param4",
"enum" => "value"
),
5 => array(
"param" => "param4",
"enum" => "value2"
),
6 => array(
"param" => "param5",
"enum" => "value"
),
7 => array(
"param" => "param6",
"enum" => "value"
),
8 => array(
"param" => "param6",
"enum" => "value2"
),
9 => array(
"param" => "param7",
"enum" => "value"
),
10 => array(
"param" => "param8",
"enum" => "value"
),
11 => array(
"param" => "param8",
"enum" => "value2"
)
)
Answer the question
In order to leave comments, you need to log in
While the current version - there is no question of any universality yet, use at your own peril and risk
Download the source : --temporarily_unavailable--
The code turned out to be greasy, so prepare cigars and popcorn
Picture with the results: https://www.screencast.com/ t/nF8qygECj
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question