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 ne transforme pas le tableau en string

nektos
nektos
Niveau 10
16 avril 2017 à 21:33:11

j'ai ce petit code :

$eventRandBB = array();

$IndividuRandomBB = array();

for($j=0;$j<24;$j++) {
	$IndividuRandomBB[] = selectIndividuRand($equipes);
	$eventRandBB[] = $IndividuRandomBB[$j]->listeEventBB[probaEventBB()];
}

$IndividuRandomBB[0] -> $eventRandBB[0]($IndividuRandomBB[0]->nom, $ArmeRandBB);

j'ai fait un print_r de $eventRandBB

Array ( [0] => recupererArmeF [1] => recupererArmeF [2] => recupererSacF [3] => recupererArmeF [4] => recupererArmeF [5] => recupererArmeF [6] => recupererArmeF [7] => recupererSacF [8] => recupererSacF [9] => recupererKitSoinF [10] => recupererArmeF [11] => recupererArmeF [12] => recupererArmeF [13] => recupererSacF [14] => recupererArmeF [15] => recupererSacF [16] => recupererArmeF [17] => recupererArmeF [18] => recupererArmeF [19] => recupererArmeF [20] => recupererSacF [21] => recupererArmeF [22] => recupererArmeF [23] => recupererArmeF ) 

Pourtant malgré tout cela j'ai les messages suivants :

Notice: Array to string conversion in /storage/h9/014/1361014/public_html/BloodBath.php on line 48

Notice: Undefined property: Individu::$Array in /storage/h9/014/1361014/public_html/BloodBath.php on line 48

Fatal error: Uncaught Error: Function name must be a string in /storage/h9/014/1361014/public_html/BloodBath.php:48 Stack trace: #0 {main} thrown in /storage/h9/014/1361014/public_html/BloodBath.php on line 48

La ligne 48 c'est : $IndividuRandomBB[0] -> $eventRandBB[0]($IndividuRandomBB[0]->nom, $ArmeRandBB);

Pour moi le problème vient du fait que php ne transforme pas $eventRandBB[0] en string et pourtant normalement ça aurait du le transformer en string c'est très bizarre

Bref si vous savez pourquoi ça fait ça je vous en serais reconnaissant

shmemory
shmemory
Niveau 8
16 avril 2017 à 21:47:28

http://php.net/manual/fr/function.explode.php

http://php.net/manual/fr/function.str-split.php

:(

shmemory
shmemory
Niveau 8
16 avril 2017 à 21:48:44

Édit: http://php.net/manual/fr/function.implode.php. *

nektos
nektos
Niveau 10
16 avril 2017 à 22:09:28

Le 16 avril 2017 à 21:47:28 shmemory a écrit :
http://php.net/manual/fr/function.explode.php

http://php.net/manual/fr/function.str-split.php

:(

je pense pas que cette fonction va m'aider :

Par exemple lorsque je fait ça :

echo $eventRandBB[0]

j'ai cela : 'recupererSacF' (c'est aléatoire mais le principale c'est que ça fonctionne)

alors que quand je fait ça :

$IndividuRandomBB[0] -> $eventRandBB[0]($IndividuRandomBB[0]->nom, $ArmeRandBB);

PHP ne transforme pas $eventRandBB[0] en 'recupererSacF' et du coup ça fait bugger mon script

nektos
nektos
Niveau 10
17 avril 2017 à 12:12:32

Le 17 avril 2017 à 09:51:31 whiteapplex a écrit :
"Function name must be a string"
Tu es sûr que "$eventRandBB[0]" est une chaine de caractère ?

bah j'ai montré le print_r est normalement oui c'est une chaine de caractere !

Enfaîte j'ai l'impression qu'il y a un problème quand je le met en méthode

JoachimDuck
JoachimDuck
Niveau 9
17 avril 2017 à 14:44:25

T'es sûr qu'il y a pas une autre façon que de mettre ton nom de fonction dans une variable ?
Au pire essaie


$tmp = eventRandBB[0];
$IndividuRandomBB[0] -> $tmp($IndividuRandomBB[0]->nom, $ArmeRandBB);

Juste pour voir.

nektos
nektos
Niveau 10
17 avril 2017 à 16:35:26

Le 17 avril 2017 à 14:44:25 JoachimDuck a écrit :
T'es sûr qu'il y a pas une autre façon que de mettre ton nom de fonction dans une variable ?
Au pire essaie


$tmp = eventRandBB[0];
$IndividuRandomBB[0] -> $tmp($IndividuRandomBB[0]->nom, $ArmeRandBB);

Juste pour voir.

on a fait ça ça a marché (merci à arsh)

Donc problème résolu il fallait utiliser une variable intermédiaire pourquoi ? ça je ne sait pas !

arsh222
arsh222
Niveau 10
17 avril 2017 à 19:14:58

Cette syntaxe marche chez moi, peut-être une version différente de PHP :(

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