how to display an array of arrays in Moodle Mustache

Re: how to display an array of arrays in Moodle Mustache

Frederik Evans -
Number of replies: 0
I don't think changing mustache file will do the job, What i would like to do, is combine the value of the subarray into that of the main array. in this case, we are now returning

the array looks like this....
Array ( [0] => Array ( [courseCode] => UBSA-C701 [courseName] => Undergraduate Biochemistry (with Intercalated Year) [routes] => Array ( [0] => Array ( [routeCode] => C701 [routeName] => Biochemistry with Intercalated Year [type] => Core [block] => 4 [year] => ) ) ) [1] => Array ( [courseCode] => UBSA-3 [courseName] => Undergraduate Biological Sciences [routes] => Array ( [0] => Array ( [routeCode] => C102 [routeName] => Biological Sciences with Cell Biology [type] => Core [block] => 3 [year] => ) [1] => Array ( [routeCode] => C103 [routeName] => Biological Sciences with Environmental Resources [type] => Core [block] => 3 [year] => ) [2] => Array ( [routeCode] => C104 [routeName] => Biological Sciences with Microbiology [type] => Core [block] => 3 [year] => ) [3] => Array ( [routeCode] => C105 [routeName] => Biological Sciences with Molecular Genetics [type] => Core [block] => 3 [year] => ) [4] => Array ( [routeCode] => C107 [routeName] => Biological Sciences with Virology [type] => Core [block] => 3 [year] => ) ) )

the first of the arrays : Array ( [0] => Array ( [courseCode] => UBSA-C701 [courseName] => Undergraduate Biochemistry (with Intercalated Year) [routes] => Array ( [0] => Array ( [routeCode] => C701 [routeName] => Biochemistry with Intercalated Year [type] => Core [block] => 4 [year] => ) ) )

contains 1 sub-array called routes
the second array, however contains 5 subarrays,
[1] => Array ( [courseCode] => UBSA-3 [courseName] => Undergraduate Biological Sciences [routes] => Array ( [0] => Array ( [routeCode] => C102 [routeName] => Biological Sciences with Cell Biology [type] => Core [block] => 3 [year] => ) [1] => Array ( [routeCode] => C103 [routeName] => Biological Sciences with Environmental Resources [type] => Core [block] => 3 [year] => ) [2] => Array ( [routeCode] => C104 [routeName] => Biological Sciences with Microbiology [type] => Core [block] => 3 [year] => ) [3] => Array ( [routeCode] => C105 [routeName] => Biological Sciences with Molecular Genetics [type] => Core [block] => 3 [year] => ) [4] => Array ( [routeCode] => C107 [routeName] => Biological Sciences with Virology [type] => Core [block] => 3 [year] => ) )

will therefore display:

UBSA-C701 : Undergraduate Biochemistry (with Intercalated Year)
Year 4 C701 Biochemistry with Intercalated Year
UBSA-3 : Undergraduate Biological Sciences
Year 3 C102 Biological Sciences with Cell Biology
Year 3 C103 Biological Sciences with Environmental Resources
Year 3 C104 Biological Sciences with Microbiology
Year 3 C105 Biological Sciences with Molecular Genetics
Year 3 C107 Biological Sciences with Virology

what we want to show is this...
UBSA-C701 : Undergraduate Biochemistry (with Intercalated Year)
UBSA-3 : Undergraduate Biological Sciences
Year 3 C102 Biological Sciences with Cell Biology
Year 3 C103 Biological Sciences with Environmental Resources
Year 3 C104 Biological Sciences with Microbiology
Year 3 C105 Biological Sciences with Molecular Genetics
Year 3 C107 Biological Sciences with Virology

so in other words, if the array has 1 and ONLY 1 sub array, then we combine, if not, leave intact

I've tried several ways, but to no success.