I have one small problem and can't move on.
I wrote this PHP code:
$d=array();
foreach(range(0, 3) as $rs) {
foreach(range(0, 5) as $c){
//here is working php code to generate '$randomRs' by '$rs' and '$c' vars..
$d[] = array('rs'.$rs => array('c'.$c => $randomRs));
}
}
echo json_encode($d);
Now JSON output is:
[{"rs0":{"c0":"bl"}},{"rs0":{"c1":"pl"}},{"rs0":{"c2":"bl"}},{"rs0":{"c3":"pl"}},{"rs0":{"c4":"pl"}},{"rs0":{"c5":"wd1"}},{"rs1":{"c0":"lk"}},{"rs1":{"c1":"gr"}},{"rs1":{"c2":"lk"}},{"rs1":{"c3":"gr"}},{"rs1":{"c4":"lk"}},{"rs1":{"c5":"gr"}},{"rs2":{"c0":"u1"}},{"rs2":{"c1":"u1"}},{"rs2":{"c2":"u1"}},{"rs2":{"c3":"wt"}},{"rs2":{"c4":"u1"}},{"rs2":{"c5":"u1"}},{"rs3":{"c0":"u1"}},{"rs3":{"c1":"u1"}},{"rs3":{"c2":"u1"}},{"rs3":{"c3":"u1"}},{"rs3":{"c4":"cl"}},{"rs3":{"c5":"ir"}}]
Which is wrong. I need to achieve this result (don't mind values) :
{
"rs0":{
"c0":"pl",
"c1":"pl",
"c2":"pl",
"c3":"pl",
"c4":"pl"
},
"rs1":{
"c0":"pl",
"c1":"pl",
"c2":"pl",
"c3":"pl",
"c4":"pl"
}
and so on...
Please show me what i am doing wrong and how can I complete this?
$d['rs'.$rs]['c'.$c] = $randomRs;array_walkfunction for that. But in general: please ask a new question for new stuff. Thanks.