In PHP è possibile utilizzare un ciclo foreach in modo tale che io ho accesso sia la chiave e il valore, ad esempio:C ciclo # foreach con valore chiave
foreach($array as $key => $value)
ho il seguente codice:
Regex regex = new Regex(pattern);
MatchCollection mc = regex.Matches(haystack);
for (int i = 0; i < mc.Count; i++)
{
GroupCollection gc = mc[i].Groups;
Dictionary<string, string> match = new Dictionary<string, string>();
for (int j = 0; j < gc.Count; j++)
{
//here
}
this.matches.Add(i, match);
}
a //here
Mi piacerebbe match.add(key, value)
ma non riesco a capire come ottenere la chiave da GroupCollection, che in questo caso dovrebbe essere il nome del gruppo di acquisizione. So che gc["goupName"].Value
contiene il valore della partita.
Qual è la chiave, qual è il valore? – kennytm