Try to understand what the code does, first. I don't work with PHP,
but I can tell that it creates a 2-D array, references array members
by column name and sets their values. It then appears to iterate
through the array and print out it's members. (Correct me if I am
wrong.)

You can easily create 2-D arrays in C#, but you will not be able to
reference them by column name. Rather you will need to reference them
by index. If the former is a necessary requirement, you can use a
DataTable to store this kind of info. That would be the best option.

On Nov 16, 11:23 am, rafael <[EMAIL PROTECTED]> wrote:
> I am new to c#...if I have a code php like this, how do i convert it
> to c#
>
> <?php
>
> $arr["US"] = array();
> $arr["US"]["Jan"] = "123";
> $arr["US"]["Feb"] = "456";
> $arr["Eur"] = array();
> $arr["Eur"]["Jan"] = "678";
> $arr["Eur"]["Feb"] = "890";
> $arr["Sing"] = array();
> $arr["Sing"]["Jan"] = "4145";
> $arr["Sing"]["Feb"] = "897";
>
> $n = array();
>
> foreach($arr as $k=>$v)
> {
>
>         foreach ($v as $k1=>$v1)
>         {
>                 //print $k." -- ".$k1." -- ".$v1."<br>";
>                 $n[$k1][$k] = $v1;
>         }
>
> }
>
> print "<pre>";
> print_r($n);
>
> ?>
>
> Thank You.

Reply via email to