Page 1 sur 1

Changer les clés d'un tableau multidimensionnel

Posté : 17 mars 2017, 13:06
par azephp
Bonjour,

Bon, je m'en reviens vers vous après 3 heures sur le problème, je n'en peux plus...

J'ai un array que voici :

Code : Tout sélectionner

D:\wamp64\www\index.php:9: array (size=4) 0 => array (size=5) 'id' => string '3' (length=1) 'groupname' => string 'test' (length=4) 'cinema_group' => string '2' (length=1) 'cinema_name' => string 'test_1' (length=6) 'cinema_location' => string 'test_location1' (length=14) 1 => array (size=5) 'id' => string '4' (length=1) 'groupname' => string 'test' (length=4) 'cinema_group' => string '2' (length=1) 'cinema_name' => string 'test_2' (length=6) 'cinema_location' => string 'test_location2' (length=14) 2 => array (size=5) 'id' => string '5' (length=1) 'groupname' => string 'test' (length=4) 'cinema_group' => string '2' (length=1) 'cinema_name' => string 'test3' (length=5) 'cinema_location' => string 'test_location3' (length=14) 3 => array (size=5) 'id' => string '6' (length=1) 'groupname' => string 'test' (length=4) 'cinema_group' => string '2' (length=1) 'cinema_name' => string 'test4' (length=5) 'cinema_location' => string 'test_location4' (length=14)
Je veux juste modifier les clés 0, 1, 2 et 3 par la valeur de l'id, pour avoir ca :

Code : Tout sélectionner

D:\wamp64\www\index.php:9: array (size=4) 3 => ... 4 => ... 5 => ... 6 => ...
Aucun moyen d'y arriver, j'ai passé 3 heures en essayant avec les fonctions php sur les tableaux, des foreach...

Si vous avez une solution, je suis preneur !

Re: Changer les clés d'un tableau multidimensionnel

Posté : 17 mars 2017, 14:34
par Mazarini
cf réponse dans l'autre thread.

Re: Changer les clés d'un tableau multidimensionnel

Posté : 20 mars 2017, 11:53
par moogli
Modération :
Le multipostage est interdit sur le forum.

Ce sujet a été verrouillé et sera supprimé sous peu.
Des réponses peuvent être apportées à cette adresse :
php-debutant/changer-les-cles-tableau-m ... 78063.html .