I have a 3D associative array.
array[string][string][string];
I want to retrieve all values at a particular 2nd index, say “hello”;
array[i]["hello"][k];
I tried using,
foreach(array[i,,k])
$display("%d",array[i]["hello"][k]);
and also,
foreach(array[i])
foreach(array[,,k])
$display("%d",array[i]["hello"][k]);
Both didnt work. Any suggestions?? Is it possible??
In reply to kambhamvivekshankar:
Hi,
Just try this way, It will work.
foreach(array[i,j,k])
$display("%d",array[i]["hello"][k]);
But in foreach just check for existence of element. If the element doesnot exists , it will return default value.
In reply to Anudeep J:
Hi Anudeep,
This approach will loop through unnecessary values of j right? Anyway to overcome it.
As you mentioned, some of the elements may not exists. I am looking for a way to constrain values of i and k to provide only valid indices. Any suggestions on how this can be achieved, are welcome.
Thank you
Regards,
KVS
In reply to kambhamvivekshankar:
Ya, that’s why I mentioned you to have exists check, so that values which are not written or does not exists are not going to be displayed.