function processArray($data) {
foreach($data as $key => $value)
if( $value['active'] )
return [$key];
elseif( !empty($value['children']) && $res = processArray($value['children'], $key))
return array_merge([$key],$res);
return null;
}
int[] arr = new int[0];
for (string s; (s = Console.ReadLine()) != "exit"; arr = arr.Concat((int.TryParse(s, out var result)) ? new int[] {result} : new int[0]).ToArray(),Console.Write(s == "sum" ? String.Format("Сумма введённых чисел = '{0}'\n", arr.Sum()) : ""))
{}for (string s,int[] arr = new int[0]; (s = Console.ReadLine()) != "exit"; arr = arr.Concat((int.TryParse(s, out var result)) ? new int[] {result} : new int[0]).ToArray(),Console.Write(s == "sum" ? String.Format("Сумма введённых чисел = '{0}'\n", arr.Sum()) : ""))
{}
int[] arr = new int[0];
for(string s;(s = Console.ReadLine()) != "exit";arr = arr.Concat((int.TryParse(s, out var result)) ? new int[] { result } : new int[0]).ToArray())
Console.Write(s == "sum"?String.Format("Сумма введённых чисел = '{0}'\n", arr.Sum()):"");for (string s,sum = "0"; (s = Console.ReadLine()) != "exit"; sum = int.TryParse(s, out var result) ? (Convert.ToInt32(sum)+result).ToString():sum)
Console.Write(s == "sum" ? String.Format("Сумма введённых чисел = '{0}'\n", sum) : "");
К чему этот массив
Какие $data и $path? И что вообще такое, в вашем понимании "конкатенировать".