За последние 24 часа нас посетили 18449 программистов и 1612 роботов. Сейчас ищут 2010 программистов ...

Преобразовать код из С# в PHP

Тема в разделе "Сделайте за меня", создана пользователем JussyJelis, 15 май 2018.

  1. JussyJelis

    JussyJelis Новичок

    С нами с:
    14 май 2018
    Сообщения:
    1
    Симпатии:
    0
    Здравствуйте, может кто сможет помочь преобразовать часть кода из С# в PHP?o_O

    Код (Text):
    1.  private ArrayList _getEventList(ArrayList file_list)
    2.         {
    3.             ArrayList event_list = new ArrayList();
    4.  
    5.             foreach (string file in file_list)
    6.             {
    7.                 StreamReader sr = new StreamReader(this._temp_directory + "\\" + file);
    8.                 string line;
    9.                 string[] res_str_array = new String[0];
    10.                 string month = "";
    11.                 string year = "";
    12.  
    13.                 while ((line = sr.ReadLine()) != null)
    14.                 {
    15.                     try
    16.                     {
    17.                         Regex reg = new Regex("([a-zA-Z]+).+([0-9]{4})");
    18.                         Match matchRes = reg.Match(line);
    19.                         if (matchRes.Success)
    20.                         {
    21.                             month = matchRes.Groups[1].Value;
    22.                             year = matchRes.Groups[2].Value;
    23.                         }
    24.  
    25.                         reg = new Regex("(\\d+)\\s+(\\d+)\\s+([0-9]+:[0-9 ]+:[0-9 ]+.[0-9])\\s+([0-9]{0,3}.[0-9]{0,2})\\s+([N|S])\\s+([0-9]{0,3}.[0-9]{0,2})\\s+([E|W])\\s+(\\d+)\\s+(\\d+.\\d+)\\s+([0-9\\.]*)\\s+([0-9\\.]*)");
    26.                         matchRes = reg.Match(line);
    27.                         if (matchRes.Success)
    28.                         {
    29.                             res_str_array = new String[9];
    30.  
    31.                             res_str_array[0] = matchRes.Groups[1].Value; //NN
    32.  
    33.                             DateTime dt = new DateTime(Convert.ToInt32(year), this._convertMothnToNumber(month), Convert.ToInt32(matchRes.Groups[2].Value));
    34.  
    35.                             res_str_array[1] = dt.ToString("d"); //Day
    36.  
    37.  
    38.                             res_str_array[2] = matchRes.Groups[3].Value.Substring(0, matchRes.Groups[3].Value.Length - 2); //Origin_time
    39.  
    40.                             if (matchRes.Groups[5].Value == "S")
    41.                             {
    42.                                 res_str_array[3] = "-" + matchRes.Groups[4].Value; //Latitude
    43.                             }
    44.                             else
    45.                             {
    46.                                 res_str_array[3] = matchRes.Groups[4].Value; //Latitude
    47.                             }
    48.                             if (matchRes.Groups[7].Value == "W")
    49.                             {
    50.                                 res_str_array[4] = "-" + matchRes.Groups[6].Value; //Longitude
    51.                             }
    52.                             else
    53.                             {
    54.                                 res_str_array[4] = matchRes.Groups[6].Value; //Longitude
    55.                             }
    56.  
    57.                             res_str_array[5] = matchRes.Groups[8].Value; //h
    58.                             res_str_array[6] = matchRes.Groups[9].Value; //MPSP
    59.  
    60.                             res_str_array[7] = matchRes.Groups[10].Value; //MPLP
    61.                             res_str_array[8] = matchRes.Groups[11].Value; //MS
    62.  
    63.                             event_list.Add(res_str_array);
    64.                         }
    65.                     }
    66.                     catch (Exception ex)
    67.                     {
    68.                         _loglist.AppendText("Будет обработано сейсмических событий " + ex.Message + "\r\n");
    69.                     }
    70.                 }
    71.             }
    72.             _loglist.AppendText("Будет обработано сейсмических событий " + event_list.Count.ToString() + "\r\n");
    73.  
    74.             return event_list;
    75.         }