Access array of array smarty

62 Views Asked by At

I have got this multidimensional array.

 [["A1",[["passed",432],["failed",0],["blocked",0],["not_run",0]]],["A2",[["passed",118],["failed",2],["blocked",0],["not_run",0]]],["A3",[["passed",332],["failed",2],["blocked",5],["not_run",0]]],["Learning",[["passed",358],["failed",1],["blocked",0],["not_run",0]]],["A4",[["passed",1923],["failed",7],["blocked",11],["not_run",0]]],["A5",[["passed",93],["failed",0],["blocked",0],["not_run",0]]]] 

Where A1,A2,A3,A4, are the keys to another array.

I have already tried

{foreach from=$new_data item=item}
<h1>{$item.[0]}</h1>
{/foreach}

but got nothing. How can I access the above array? Is there any other way apart from using foreach loop?

Expected Result:
Key: A1 
Value: [["passed",93],["failed",0],["blocked",0],["not_run",0]]
Similarly for other keys too. 
1

There are 1 best solutions below

0
On
foreach ($a as $a_new=>$a_array) { 
     foreach ($a_array as $a_new_a) { 
          echo $a_new_a; 
     } 
 } 

@Anubhav You have to learn multidimensional array how it's work, you need to use two for each loop for accessing data