Probleme avec Array()

porcinus Messages postés 19 Date d'inscription lundi 18 avril 2005 Statut Membre Dernière intervention 31 août 2007 - 1 févr. 2007 à 03:18
porcinus Messages postés 19 Date d'inscription lundi 18 avril 2005 Statut Membre Dernière intervention 31 août 2007 - 1 févr. 2007 à 18:09
Bonjour ,

je tiens tout d'abord à précisé que je suis débutant

mon code est destiné à l'affichage de rank de "Mani Admin Plugin"

voici mon code :


<?php

$entrer=fopen("entrer.txt","r");

$i = 0;

while ($i < 1)

{

$entrer1 = fgets($entrer);

$i++;

}

fclose($entrer);

/////////////////////////////////////////////////

$mrd=fopen("mrd.txt","r");

$i = 0;

while ($i < 1)

{

$mrd1 = fgets($mrd);

$i++;

}

fclose($mrd);

/////////////////////////////////////////////////

$ouvretop=fopen("mani_ranks.txt","r");

$i = 0;

while ($i < 1)

{

$temptop1 = fgets($ouvretop);

$i++;

}

fclose($ouvretop);

$tgtop1 = str_replace(",",'","',$temptop1);

$top1 = '"' . $tgtop1 . '"';       

$top1 = str_replace($entrer1,"",$top1);

$top1oki = array($top1);

echo $top1oki[0];

?>


- entrer.txt contient un retour à la ligne


 - $top1 contient :
"STEAM_0:0:7385504","83.198.235.194","1170277288","1","1334","187","188","374","1","0","7308","46758","65","253","299","119","210","63","41","40","62","75","0","0","10","44","65","1","0","25","8","28","7","1","0","16","5","0","0","0","1","25","1","0","0","0","0","0","4557","1090","0","0","0","0","0","0","1","0","0","0","21","0","0","8","Wazaa. .:'Delirium/Fr':."

mais echo $top1oki[0] retourne :

"STEAM_0:0:7385504","83.198.235.194","1170277288","1","1334","187","188","374","1","0","7308","46758","65","253","299","119","210","63","41","40","62","75","0","0","10","44","65","1","0","25","8","28","7","1","0","16","5","0","0","0","1","25","1","0","0","0","0","0","4557","1090","0","0","0","0","0","0","1","0","0","0","21","0","0","8","Wazaa. .:'Delirium/Fr':."

et echo $top1oki[1] retourne rien du tout .

Merci pour votre aide

2 réponses

malalam Messages postés 10839 Date d'inscription lundi 24 février 2003 Statut Membre Dernière intervention 2 mars 2010 25
1 févr. 2007 à 08:18
Hello,

array () transforme ta variable en tableau, certes...mais elle ne contient dans ce cas qu'une seule valeur, qui est à l'index 0.
C'est tout à fait normal. PHP ne peut pas deviner comment tu veux scinder ta chaîne.
A toi de le lui dire :
$top1oki= explode (',', $top1);
0
porcinus Messages postés 19 Date d'inscription lundi 18 avril 2005 Statut Membre Dernière intervention 31 août 2007
1 févr. 2007 à 18:09
okey , merci beaucoup ;)
0
Rejoignez-nous