CONNEXION
  • RetourJeux
    • Sorties
    • Hit Parade
    • Les + populaires
    • Les + attendus
    • Soluces
    • Tous les Jeux
    • Gaming
  • RetourActu Gaming
    • News
    • Astuces
    • Tests
    • Previews
    • Toute l'actu gaming
  • RetourBons plans
    • Bons plans
    • Bons plans Smartphone
    • Bons plans Hardware
    • Bons plans Image et Son
    • Bons plans Amazon
    • Bons plans Cdiscount
    • Bons plans Decathlon
    • Bons plans Fnac
    • Tous les Bons plans
  • RetourJVTech
    • Actus High-Tech
    • Intelligence Artificielle
    • Smartphones
    • Mobilité urbaine
    • Hardware
    • Image et son
    • Tutoriels
    • Tests produits High-Tech
    • Guides d'achat High-Tech
    • JVTech
  • RetourCulture
    • Actus Culture
    • Culture
  • RetourVidéos
    • A la une
    • Gaming Live
    • Vidéos Tests
    • Vidéos Previews
    • Gameplay
    • Trailers
    • Chroniques
    • Replay Web TV
    • Toutes les vidéos
  • RetourForums
    • Hardware PC
    • PS5
    • Switch 2
    • Xbox Series
    • Switch
    • Pokemon pocket
    • FC 25 Ultimate Team
    • League of Legends
    • Tous les Forums
  • PC
  • PS5
  • Xbox Series
  • Switch 2
  • PS4
  • One
  • Switch
  • iOS
  • Android
  • MMO
  • RPG
  • FPS
En ce moment Genshin Impact Valhalla Breath of the wild Animal Crossing GTA 5 Red dead 2
Liste des sujets

PHP : Utilisé plus facilement une quarantaine de variable

nektos
nektos
Niveau 10
13 avril 2017 à 21:37:22

Bonjour

j'ai commencé à faire ce petit site test : https://hgs1825.000webhostapp.com/index.html

comme vous pouvez le constater j'ai mis énormément d'input qui ont chacun un name unique (que j'ai du écrire à la main)

ensuite on vient sur confirmation.php

dont voici le code (Attention ça va être gros mais ne vous inquiétez pas je vais vous résumer ma requête

<?php
class Individu {
  public $nom;
  public $avatar;
  public $compagnon;
  public $enVie = true;
  public $mentale = 5;
  public $faimSoif = 5;
  public $inventaire = array();
  public $bloodbathFini = false;
  public function recupererArme($nom,$ArmeRandBB) {
	  echo $this . " " . "recupere" . " " . "un(e)/des" . $ArmeRandBB -> nomArme;
	  $inventaire[] = $ArmeRandBB;
	  $bloodbathFini = true;
  }
  public function recupererSac($nom) {
	  echo $this -> nom . " " . "recupere un sac";
	  $inventaire[] = "sac";
	  $bloodbathFini = true;
  }
  public function recupererKitSoin($nom) {
	  echo $this -> nom . " " . "recupere un kit de premier soin";
	  $inventaire[] = "kitSoin";
	  $bloodbathFini = true;
  }
  public function recupererPoison($nom) {
	  echo $this -> nom . " " . "recupere une fiole de poison";
	  $inventaire[] = "poison";
	  $bloodbathFini = true;
  }
  public function recupererExplosif($nom) {
	  echo $this -> nom . " " . "recupere un sac rempli d'explosif";
	  $inventaire[] = "sacExplosif";
	  $bloodbathFini = true;
  }
  public function __construct($nom, $avatar)
  {
    $this -> nom = $nom;
	$this -> avatar = $avatar;
	$this -> compagnon = $compagnon;
  }
}
$Individu1d1 = new Individu($_POST['nom1d1'], $_POST['imageURL1d1'],$_POST['nom2d1']);
$Individu2d1 = new Individu($_POST['nom2d1'], $_POST['imageURL2d1'],$_POST['nom1d1']);

$Individu1d2 = new Individu($_POST['nom1d2'], $_POST['imageURL1d2'],$_POST['nom2d2']);
$Individu2d2 = new Individu($_POST['nom2d2'], $_POST['imageURL2d2'],$_POST['nom1d2']);

$Individu1d3 = new Individu($_POST['nom1d3'], $_POST['imageURL1d3'],$_POST['nom2d3']);
$Individu2d3 = new Individu($_POST['nom2d3'], $_POST['imageURL2d3'],$_POST['nom1d3']);

$Individu1d4 = new Individu($_POST['nom1d4'], $_POST['imageURL1d4'],$_POST['nom2d4']);
$Individu2d4 = new Individu($_POST['nom2d4'], $_POST['imageURL2d4'],$_POST['nom1d4']);

$Individu1d5 = new Individu($_POST['nom1d5'], $_POST['imageURL1d5'],$_POST['nom2d5']);
$Individu2d5 = new Individu($_POST['nom2d5'], $_POST['imageURL2d5'],$_POST['nom1d5']);

$Individu1d6 = new Individu($_POST['nom1d6'], $_POST['imageURL1d6'],$_POST['nom2d6']);
$Individu2d6 = new Individu($_POST['nom2d6'], $_POST['imageURL2d6'],$_POST['nom1d6']);

$Individu1d7 = new Individu($_POST['nom1d7'], $_POST['imageURL1d7'],$_POST['nom2d7']);
$Individu2d7 = new Individu($_POST['nom2d7'], $_POST['imageURL2d7'],$_POST['nom1d7']);

$Individu1d8 = new Individu($_POST['nom1d8'], $_POST['imageURL1d8'],$_POST['nom2d8']);
$Individu2d8 = new Individu($_POST['nom2d8'], $_POST['imageURL2d8'],$_POST['nom1d8']);

$Individu1d9 = new Individu($_POST['nom1d9'], $_POST['imageURL1d9'],$_POST['nom2d9']);
$Individu2d9 = new Individu($_POST['nom2d9'], $_POST['imageURL2d9'],$_POST['nom1d9']);

$Individu1d10 = new Individu($_POST['nom1d10'], $_POST['imageURL1d10'],$_POST['nom2d10']);
$Individu2d10 = new Individu($_POST['nom2d10'], $_POST['imageURL2d10'],$_POST['nom1d10']);

$Individu1d11 = new Individu($_POST['nom1d11'], $_POST['imageURL1d11'],$_POST['nom2d11']);
$Individu2d11 = new Individu($_POST['nom2d11'], $_POST['imageURL2d11'],$_POST['nom1d11']);

$Individu1d12 = new Individu($_POST['nom1d12'], $_POST['imageURL1d12'],$_POST['nom2d12']);
$Individu2d12 = new Individu($_POST['nom2d12'], $_POST['imageURL2d12'],$_POST['nom1d12']);
?>

:d) Comme vous pouvez le constater je met en place une Classe Individu Et la manière dont elle va être construite

elle prend en paramètre : le nom, l'url de l'image et le nom de son coéquipier (sa aussi j'ai du tout faire à la main)

et maintenant je me rend compte que je vais avoir besoin de manipuler énormément les

Individu1d1
Individu2d2
...

car dans la prochaine page je doit choisir aléatoirement une de ses personnes

:mac: Alors je vous pose la question : aurais-je pu simplifier tout ça ? en faisant des boucles for ? :mac:

Et j'ai une question additionnelle

Imaginons que dans confirmation.php je décide de mettre un array qui stock toutes les instances d'Individu

Comment dois-je faire pour que je puisse utiliser ce tableau dans une autre page (bloodbath.php)

arsh222
arsh222
Niveau 10
13 avril 2017 à 23:13:49

tu peux mettre des crochets dans les name des inputs pour les récupérer sous forme de tableau, par exemple :
<input name="equipes[0]['joueur1']['nom']">
<input name="equipes[0]['joueur1']['imageurl']">
<input name="equipes[0]['joueur2']['nom']">
<input name="equipes[0]['joueur2']['imageurl']">

tu fais ça pour toutes les équipes, c'est assez facile à faire avec une boucle (en changeant le chiffre du premier [0]), ça te donnera un tableau où chaque équipe est un sous-tableau qui reprend ses deux joueurs, qui eux-même reprennent le nom et l'url : $_POST['equipes'][2]['joueur1']['nom'] bien sûr c'est un exemple, tu peux faire une autre structure

pour passer des valeurs d'une page à une autre, la solution standard est la base de données mais à défaut tu pourrais sérialiser les tableaux et les mettre dans des fichiers, ou peut-être voir si memcached peut servir à ça...? je ne sais pas:(

nektos
nektos
Niveau 10
13 avril 2017 à 23:30:09

Le 13 avril 2017 à 23:13:49 arsh222 a écrit :
tu peux mettre des crochets dans les name des inputs pour les récupérer sous forme de tableau, par exemple :
<input name="equipes[0]['joueur1']['nom']">
<input name="equipes[0]['joueur1']['imageurl']">
<input name="equipes[0]['joueur2']['nom']">
<input name="equipes[0]['joueur2']['imageurl']">

tu fais ça pour toutes les équipes, c'est assez facile à faire avec une boucle (en changeant le chiffre du premier [0]), ça te donnera un tableau où chaque équipe est un sous-tableau qui reprend ses deux joueurs, qui eux-même reprennent le nom et l'url : $_POST['equipes'][2]['joueur1']['nom'] bien sûr c'est un exemple, tu peux faire une autre structure

pour passer des valeurs d'une page à une autre, la solution standard est la base de données mais à défaut tu pourrais sérialiser les tableaux et les mettre dans des fichiers, ou peut-être voir si memcached peut servir à ça...? je ne sais pas:(

Merci beaucoup pour ton explication

et sinon pour la deuxieme question au début j'avais jugé mauvais d"utilisé le mysql car je me suis dit qu'à cause des images ça allait tout surchargé mais finalement vu que c'est simplement des URL d'image la ça devient tout de suite plus simple car on peut les mettre facilement dans une page HTML

nektos
nektos
Niveau 10
14 avril 2017 à 00:20:36

j'ai un problème erreur 500

voila le code :

<?php
class Individu {
  public $nom;
  public $avatar;
  public $compagnon;
  public $enVie = true;
  public $mentale = 5;
  public $faimSoif = 5;
  public $inventaire = array();
  public $bloodbathFini = false;
  public function recupererArme($nomRandBB,$ArmeRandBB) {
	  echo $this . " " . "recupere" . " " . "un(e)/des" . $ArmeRandBB -> nomArme;
	  $inventaire[] = $ArmeRandBB;
	  $bloodbathFini = true;
  }
  public function recupererSac($nomRandBB) {
	  echo $this -> nom . " " . "recupere un sac";
	  $inventaire[] = "sac";
	  $bloodbathFini = true;
  }
  public function recupererKitSoin($nomRandBB) {
	  echo $this -> nom . " " . "recupere un kit de premier soin";
	  $inventaire[] = "kitSoin";
	  $bloodbathFini = true;
  }
  public function recupererPoison($nomRandBB) {
	  echo $this -> nom . " " . "recupere une fiole de poison";
	  $inventaire[] = "poison";
	  $bloodbathFini = true;
  }
  public function recupererExplosif($nomRandBB) {
	  echo $this -> nom . " " . "recupere un sac rempli d'explosif";
	  $inventaire[] = "sacExplosif";
	  $bloodbathFini = true;
  }
  public function __construct($nom, $avatar)
  {
    $this -> nom = $nom;
	$this -> avatar = $avatar;
	$this -> compagnon = $compagnon;
  }
}
for($i=0;$i<24;$i++) {
	$equipeNumero = 0;
	$Individu1d . equipeNumero = new Individu($_POST["equipes[" . equipeNumero . "]['joueur1']['nom']"], $_POST["equipes[" . equipeNumero . "]['joueur1']['imageurl']"], $_POST["equipes[" . equipeNumero . "]['joueur2']['nom']"]);
	$Individu2d . equipeNumero = new Individu($_POST["equipes[" . equipeNumero . "]['joueur2']['nom']"], $_POST["equipes[" . equipeNumero . "]['joueur2']['imageurl']"], $_POST["equipes[" . equipeNumero . "]['joueur1']['nom']"]);
	$equipeNumero = $equipeNumero + 1;
}
?>

Note : ce fichier est confirmation.php

je vois vraiment pas ou est l'erreur même si je suspecte la boucle for

note : j'ai changé le name de tout les input dans index.html

arsh222
arsh222
Niveau 10
14 avril 2017 à 01:11:10

Certains trucs n'ont aucun sens :hap:

$Individu1d . equipeNumero = ...

tu ne peux pas générer tes noms de variable comme ça à la volée (enfin c'est possible mais pas comme ça et puis là c'est hors-sujet)

Utilise plutôt un tableau : $equipes[$equipeNumero]['Individu1d'] = ...

même chose pour
$_POST["equipes[" . equipeNumero . "]['joueur1']['nom']"]
les inputs dans post sont déjà convertis en tableaux :
$tab_equipes = $_POST['equipes']; $tab_equipes[$equipeNumero]['joueur2']['nom'] = ...;

nektos
nektos
Niveau 10
14 avril 2017 à 10:49:33

bon du coup j'ai fait ça :

$tab_equipes = $_POST['equipes'];
for($i=1;$i<12;$i++) {
	$equipes[$i]['Individu1'] = new Individu($tab_equipes[$i]['joueur1']['nom'], $tab_equipes[$i]['joueur1']['imageurl'], $tab_equipes[$i]['joueur2']['nom']);
	$equipes[$i]['Individu2'] = new Individu($tab_equipes[$i]['joueur2']['nom'], $tab_equipes[$i]['joueur1']['imageurl'], $tab_equipes[$i]['joueur1']['nom']);
}

mais ça n'a pas l'air de fonctionner quand je fait un echo et la je sais vraiment pas d'ou ça vient j'ai fait plusieurs teste en tentant quelques truc

par exemple je fait ça :

echo $equipes[1]['Individu1'] -> nom;

rien ne s'affiche

Message édité le 14 avril 2017 à 10:52:19 par nektos
arsh222
arsh222
Niveau 10
14 avril 2017 à 11:47:29

fais un var_dump de $_POST et $equipes

nektos
nektos
Niveau 10
14 avril 2017 à 12:13:30

var dump de $_POST : (attention c'est gros et brut) go voir ma conclusion en bas

array(1) { ["equipes"]=> array(12) { [1]=> array(2) { ["'joueur1'"]=> array(2) { ["'nom'"]=> string(5) "test1" ["'imageurl'"]=> string(68) "http://image.noelshack.com/fichiers/2016/24/1466366209-risitas24.png" } ["'joueur2'"]=> array(2) { ["'nom'"]=> string(5) "test2" ["'imageurl'"]=> string(68) "http://image.noelshack.com/fichiers/2016/24/1466366197-risitas10.png" } } [2]=> array(2) { ["'joueur1'"]=> array(2) { ["'nom'"]=> string(5) "test3" ["'imageurl'"]=> string(84) "http://image.noelshack.com/fichiers/2017/10/1489162412-1465686632-jesuus-risitas.gif" } ["'joueur2'"]=> array(2) { ["'nom'"]=> string(5) "test4" ["'imageurl'"]=> string(67) "http://image.noelshack.com/fichiers/2016/50/1482027315-perplexe.png" } } [3]=> array(2) { ["'joueur1'"]=> array(2) { ["'nom'"]=> string(5) "test5" ["'imageurl'"]=> string(70) "http://image.noelshack.com/fichiers/2016/46/1479347417-rambositas1.png" } ["'joueur2'"]=> array(2) { ["'nom'"]=> string(5) "test6" ["'imageurl'"]=> string(65) "http://image.noelshack.com/fichiers/2016/26/1467335935-jesus1.png" } } [4]=> array(2) { ["'joueur1'"]=> array(2) { ["'nom'"]=> string(5) "test7" ["'imageurl'"]=> string(69) "http://image.noelshack.com/fichiers/2016/30/1469541957-risitas198.png" } ["'joueur2'"]=> array(2) { ["'nom'"]=> string(5) "test8" ["'imageurl'"]=> string(69) "http://image.noelshack.com/fichiers/2016/30/1469541952-risitas182.png" } } [5]=> array(2) { ["'joueur1'"]=> array(2) { ["'nom'"]=> string(5) "test9" ["'imageurl'"]=> string(69) "http://image.noelshack.com/fichiers/2016/24/1466366648-risitas115.png" } ["'joueur2'"]=> array(2) { ["'nom'"]=> string(6) "test10" ["'imageurl'"]=> string(66) "http://image.noelshack.com/fichiers/2016/38/1474488637-jesus26.png" } } [6]=> array(2) { ["'joueur1'"]=> array(2) { ["'nom'"]=> string(6) "test11" ["'imageurl'"]=> string(66) "http://image.noelshack.com/fichiers/2016/38/1474719452-jesus56.png" } ["'joueur2'"]=> array(2) { ["'nom'"]=> string(6) "test12" ["'imageurl'"]=> string(68) "http://image.noelshack.com/fichiers/2016/24/1466366602-risitas94.png" } } [7]=> array(2) { ["'joueur1'"]=> array(2) { ["'nom'"]=> string(6) "test13" ["'imageurl'"]=> string(69) "http://image.noelshack.com/fichiers/2016/30/1469971032-risitas246.png" } ["'joueur2'"]=> array(2) { ["'nom'"]=> string(6) "test14" ["'imageurl'"]=> string(69) "http://image.noelshack.com/fichiers/2016/38/1474490303-risitas468.png" } } [8]=> array(2) { ["'joueur1'"]=> array(2) { ["'nom'"]=> string(6) "test15" ["'imageurl'"]=> string(69) "http://image.noelshack.com/fichiers/2016/38/1474490235-risitas434.png" } ["'joueur2'"]=> array(2) { ["'nom'"]=> string(6) "test16" ["'imageurl'"]=> string(69) "http://image.noelshack.com/fichiers/2016/30/1469541959-risitas206.png" } } [9]=> array(2) { ["'joueur1'"]=> array(2) { ["'nom'"]=> string(6) "test17" ["'imageurl'"]=> string(80) "http://image.noelshack.com/fichiers/2016/51/1482325936-jesus-chauve-eco-plus.png" } ["'joueur2'"]=> array(2) { ["'nom'"]=> string(6) "test18" ["'imageurl'"]=> string(76) "http://image.noelshack.com/fichiers/2016/47/1480064732-1467335935-jesus4.png" } } [10]=> array(2) { ["'joueur1'"]=> array(2) { ["'nom'"]=> string(6) "test19" ["'imageurl'"]=> string(72) "http://image.noelshack.com/fichiers/2017/02/1484173541-cc-risitas596.png" } ["'joueur2'"]=> array(2) { ["'nom'"]=> string(6) "test20" ["'imageurl'"]=> string(64) "http://image.noelshack.com/fichiers/2016/47/1480081450-ris42.png" } } [11]=> array(2) { ["'joueur1'"]=> array(2) { ["'nom'"]=> string(6) "test21" ["'imageurl'"]=> string(69) "http://image.noelshack.com/fichiers/2016/38/1474755095-risitas719.png" } ["'joueur2'"]=> array(2) { ["'nom'"]=> string(6) "test22" ["'imageurl'"]=> string(73) "http://image.noelshack.com/fichiers/2016/39/1474977832-sadchanclaloop.gif" } } [12]=> array(2) { ["'joueur1'"]=> array(2) { ["'nom'"]=> string(6) "test23" ["'imageurl'"]=> string(66) "http://image.noelshack.com/fichiers/2016/38/1474488574-jesus50.png" } ["'joueur2'"]=> array(2) { ["'nom'"]=> string(6) "test24" ["'imageurl'"]=> string(69) "http://image.noelshack.com/fichiers/2016/38/1474794851-risitas766.gif" } } } }

:mac: Personnellement la j'en conclus que le $_POST fait son taff vu que je vois tout mes input, mes liens d'images etc ... :mac:

var dump de $equipe (la encore conclusion a la fin)

array(11) { [1]=> array(2) { ["Individu1"]=> object(Individu)#1 (8) { ["nom"]=> NULL ["avatar"]=> NULL ["compagnon"]=> NULL ["enVie"]=> bool(true) ["mentale"]=> int(5) ["faimSoif"]=> int(5) ["inventaire"]=> array(0) { } ["bloodbathFini"]=> bool(false) } ["Individu2"]=> object(Individu)#2 (8) { ["nom"]=> NULL ["avatar"]=> NULL ["compagnon"]=> NULL ["enVie"]=> bool(true) ["mentale"]=> int(5) ["faimSoif"]=> int(5) ["inventaire"]=> array(0) { } ["bloodbathFini"]=> bool(false) } } [2]=> array(2) { ["Individu1"]=> object(Individu)#3 (8) { ["nom"]=> NULL ["avatar"]=> NULL ["compagnon"]=> NULL ["enVie"]=> bool(true) ["mentale"]=> int(5) ["faimSoif"]=> int(5) ["inventaire"]=> array(0) { } ["bloodbathFini"]=> bool(false) } ["Individu2"]=> object(Individu)#4 (8) { ["nom"]=> NULL ["avatar"]=> NULL ["compagnon"]=> NULL ["enVie"]=> bool(true) ["mentale"]=> int(5) ["faimSoif"]=> int(5) ["inventaire"]=> array(0) { } ["bloodbathFini"]=> bool(false) } } [3]=> array(2) { ["Individu1"]=> object(Individu)#5 (8) { ["nom"]=> NULL ["avatar"]=> NULL ["compagnon"]=> NULL ["enVie"]=> bool(true) ["mentale"]=> int(5) ["faimSoif"]=> int(5) ["inventaire"]=> array(0) { } ["bloodbathFini"]=> bool(false) } ["Individu2"]=> object(Individu)#6 (8) { ["nom"]=> NULL ["avatar"]=> NULL ["compagnon"]=> NULL ["enVie"]=> bool(true) ["mentale"]=> int(5) ["faimSoif"]=> int(5) ["inventaire"]=> array(0) { } ["bloodbathFini"]=> bool(false) } } [4]=> array(2) { ["Individu1"]=> object(Individu)#7 (8) { ["nom"]=> NULL ["avatar"]=> NULL ["compagnon"]=> NULL ["enVie"]=> bool(true) ["mentale"]=> int(5) ["faimSoif"]=> int(5) ["inventaire"]=> array(0) { } ["bloodbathFini"]=> bool(false) } ["Individu2"]=> object(Individu)#8 (8) { ["nom"]=> NULL ["avatar"]=> NULL ["compagnon"]=> NULL ["enVie"]=> bool(true) ["mentale"]=> int(5) ["faimSoif"]=> int(5) ["inventaire"]=> array(0) { } ["bloodbathFini"]=> bool(false) } } [5]=> array(2) { ["Individu1"]=> object(Individu)#9 (8) { ["nom"]=> NULL ["avatar"]=> NULL ["compagnon"]=> NULL ["enVie"]=> bool(true) ["mentale"]=> int(5) ["faimSoif"]=> int(5) ["inventaire"]=> array(0) { } ["bloodbathFini"]=> bool(false) } ["Individu2"]=> object(Individu)#10 (8) { ["nom"]=> NULL ["avatar"]=> NULL ["compagnon"]=> NULL ["enVie"]=> bool(true) ["mentale"]=> int(5) ["faimSoif"]=> int(5) ["inventaire"]=> array(0) { } ["bloodbathFini"]=> bool(false) } } [6]=> array(2) { ["Individu1"]=> object(Individu)#11 (8) { ["nom"]=> NULL ["avatar"]=> NULL ["compagnon"]=> NULL ["enVie"]=> bool(true) ["mentale"]=> int(5) ["faimSoif"]=> int(5) ["inventaire"]=> array(0) { } ["bloodbathFini"]=> bool(false) } ["Individu2"]=> object(Individu)#12 (8) { ["nom"]=> NULL ["avatar"]=> NULL ["compagnon"]=> NULL ["enVie"]=> bool(true) ["mentale"]=> int(5) ["faimSoif"]=> int(5) ["inventaire"]=> array(0) { } ["bloodbathFini"]=> bool(false) } } [7]=> array(2) { ["Individu1"]=> object(Individu)#13 (8) { ["nom"]=> NULL ["avatar"]=> NULL ["compagnon"]=> NULL ["enVie"]=> bool(true) ["mentale"]=> int(5) ["faimSoif"]=> int(5) ["inventaire"]=> array(0) { } ["bloodbathFini"]=> bool(false) } ["Individu2"]=> object(Individu)#14 (8) { ["nom"]=> NULL ["avatar"]=> NULL ["compagnon"]=> NULL ["enVie"]=> bool(true) ["mentale"]=> int(5) ["faimSoif"]=> int(5) ["inventaire"]=> array(0) { } ["bloodbathFini"]=> bool(false) } } [8]=> array(2) { ["Individu1"]=> object(Individu)#15 (8) { ["nom"]=> NULL ["avatar"]=> NULL ["compagnon"]=> NULL ["enVie"]=> bool(true) ["mentale"]=> int(5) ["faimSoif"]=> int(5) ["inventaire"]=> array(0) { } ["bloodbathFini"]=> bool(false) } ["Individu2"]=> object(Individu)#16 (8) { ["nom"]=> NULL ["avatar"]=> NULL ["compagnon"]=> NULL ["enVie"]=> bool(true) ["mentale"]=> int(5) ["faimSoif"]=> int(5) ["inventaire"]=> array(0) { } ["bloodbathFini"]=> bool(false) } } [9]=> array(2) { ["Individu1"]=> object(Individu)#17 (8) { ["nom"]=> NULL ["avatar"]=> NULL ["compagnon"]=> NULL ["enVie"]=> bool(true) ["mentale"]=> int(5) ["faimSoif"]=> int(5) ["inventaire"]=> array(0) { } ["bloodbathFini"]=> bool(false) } ["Individu2"]=> object(Individu)#18 (8) { ["nom"]=> NULL ["avatar"]=> NULL ["compagnon"]=> NULL ["enVie"]=> bool(true) ["mentale"]=> int(5) ["faimSoif"]=> int(5) ["inventaire"]=> array(0) { } ["bloodbathFini"]=> bool(false) } } [10]=> array(2) { ["Individu1"]=> object(Individu)#19 (8) { ["nom"]=> NULL ["avatar"]=> NULL ["compagnon"]=> NULL ["enVie"]=> bool(true) ["mentale"]=> int(5) ["faimSoif"]=> int(5) ["inventaire"]=> array(0) { } ["bloodbathFini"]=> bool(false) } ["Individu2"]=> object(Individu)#20 (8) { ["nom"]=> NULL ["avatar"]=> NULL ["compagnon"]=> NULL ["enVie"]=> bool(true) ["mentale"]=> int(5) ["faimSoif"]=> int(5) ["inventaire"]=> array(0) { } ["bloodbathFini"]=> bool(false) } } [11]=> array(2) { ["Individu1"]=> object(Individu)#21 (8) { ["nom"]=> NULL ["avatar"]=> NULL ["compagnon"]=> NULL ["enVie"]=> bool(true) ["mentale"]=> int(5) ["faimSoif"]=> int(5) ["inventaire"]=> array(0) { } ["bloodbathFini"]=> bool(false) } ["Individu2"]=> object(Individu)#22 (8) { ["nom"]=> NULL ["avatar"]=> NULL ["compagnon"]=> NULL ["enVie"]=> bool(true) ["mentale"]=> int(5) ["faimSoif"]=> int(5) ["inventaire"]=> array(0) { } ["bloodbathFini"]=> bool(false) } } }

:mac: La on a un problème au niveau de l'assignation car on remaruqe les "nom" = NULL ce qui signifie qu'il y a un problème mais je ne sais pas ou, surement la boucle for mais je ne cerne pas

arsh222
arsh222
Niveau 10
14 avril 2017 à 16:15:31

je vois que dans le $_POST il y a ["'joueur1'"], il y a une paire de guillemets en trop, c'est peut-être de ma faute, essaie

<input name="equipes[0][joueur1][nom]">

au lieu de

<input name="equipes[0]['joueur1']['nom']">

nektos
nektos
Niveau 10
14 avril 2017 à 16:26:23

Le 14 avril 2017 à 16:15:31 arsh222 a écrit :
je vois que dans le $_POST il y a ["'joueur1'"], il y a une paire de guillemets en trop, c'est peut-être de ma faute, essaie

<input name="equipes[0][joueur1][nom]">

au lieu de

<input name="equipes[0]['joueur1']['nom']">

effectivement ça fonctionne merci

Sous forums
  • Aide à l'achat Mac
  • Création de sites web
  • Internet
  • Macintosh
  • Création de Jeux
  • Linux
  • Programmation
  • Steam Deck
  • Hardware
La vidéo du moment