EspañolDeutschFrançaisItalianoPortuguêsРусскийΕλληνικά日本語中文(简体)हिन्दी; हिंदीالعربية
Als Standardsprache festlegen
PF-Fragen - Forum

Würde wie nehmen ein assoziatives Array zu und die Werte des Schlüssels??

Mi array asociativo es:

$valores = array ( 1 => "Juan", 3 => "Victor", 7 => "Valeria" );

Si lo recorro usando foreach, in der Variablen $valor se guardan los valores

foreach ( $valores in $valor ) {
   echo $valor;
}

¿Cómo puedo obtener en vez de los valores, las claves de dichos valores? D. h., in diesem Fall, { 1, 3, 7 }

Share on Facebook Tweet about this on Twitter Share on Google+ Pin on Pinterest Share on Reddit Share on VK Share on StumbleUpon Share on Tumblr Share on LinkedIn Email this to someone Print this page
javi_menes gestellte tut 7 Jahre
1 Antworten
Beste Antwort

Puedes hacerlo así:

foreach ( $valores as $clave => $valor ) {
echo $clave;
}

Auf diese Weise, en cada iteracción, en la variables $clave y $valor se almacenan sus respectivos valores de clave y valor.

Share on Facebook Tweet about this on Twitter Share on Google+ Pin on Pinterest Share on Reddit Share on VK Share on StumbleUpon Share on Tumblr Share on LinkedIn Email this to someone Print this page
diegodel genannten macht 7 Jahre