Précédent   Forum des professionnels en informatique > PHP > PHP & SGBD > PHP & PostgreSQL
PHP & PostgreSQL Forum d'entraide sur PostgreSQL avec PHP. Avant de poster -> FAQ PostgreSQL, Cours PostgreSQL. Pour les questions concernant le moteur PostgreSQL plutôt que les fonctions PHP, merci d'utiliser le forum PostgreSQL.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 12/01/2011, 18h05   #1
Membre actif
 
Homme David
Inscription : septembre 2007
Messages : 353
Détails du profil
Informations personnelles :
Nom : Homme David
Localisation : France

Informations professionnelles :
Secteur : Agroalimentaire - Agriculture

Informations forums :
Inscription : septembre 2007
Messages : 353
Points : 195
Points : 195
Par défaut Résultat de requete dans un tableau

Bonjour,

j'ai la requete ci-dessous qui me renvoie les tableaux ci-dessous également


Code :
1
2
3
4
5
6
7
8
$datax = array();
$datay = array();
while ($row=pg_fetch_array($result)) {
array_push($datax, $row['mois']);
array_push($datay, $row['round']);
}
print_r ($datax);
print_r ($datay);
Code :
Array ( [0] => 0901 [1] => 0902 [2] => 0903 [3] => 0904 [4] => 0905 [5] => 0906 [6] => 0907 [7] => 0908 [8] => 0909 [9] => 0910 [10] => 0911 [11] => 0912 [12] => 1001 [13] => 1002 [14] => 1003 [15] => 1004 [16] => 1005 [17] => 1006 [18] => 1007 [19] => 1008 [20] => 1009 [21] => 1010 [22] => 1011 [23] => 1012 ) Array ( [0] => 1.82 [1] => 1.81 [2] => 1.23 [3] => 1.89 [4] => 1.73 [5] => 1.62 [6] => 1.66 [7] => 1.70 [8] => 1.80 [9] => 1.73 [10] => 1.67 [11] => 1.74 [12] => 1.84 [13] => 1.59 [14] => 1.84 [15] => 1.79 [16] => 1.65 [17] => 1.49 [18] => 1.51 [19] => 1.57 [20] => 1.70 [21] => 1.73 [22] => 1.62 [23] => 1.65 )
Mon souci est que c'est pour utiliser dans Artichow et qu'il me faut des array du type : Array (0901,0902,0903,0903,0904)

Comment faire donc pour transformer ces tableaux?

Merci d'avance
damalaan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 12/01/2011, 18h24   #2
Modérateur
 
Avatar de sabotage
 
Homme Vincent
Inscription : juillet 2005
Messages : 14 929
Détails du profil
Informations personnelles :
Nom : Homme Vincent

Informations forums :
Inscription : juillet 2005
Messages : 14 929
Points : 16 381
Points : 16 381
Les tableaux que tu obtiens sont bons.
Des tableaux sans index ca n'existe pas en PHP.
sabotage est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 12/01/2011, 19h32   #3
Membre Expert
 
Avatar de Fench
 
Inscription : mai 2002
Messages : 1 654
Détails du profil
Informations personnelles :
Localisation : France

Informations forums :
Inscription : mai 2002
Messages : 1 654
Points : 1 807
Points : 1 807
Bonsoir,

Cad que tu veux un truc du genre:
Code :
1
2
 
$values = array(.., .., ..);
__________________
Actuellement AI à l'INRA
fait gagner du temps à ceux qui aident , donc un message avec la balise résolu laisse plus de temps pour résoudre d'autres problèmes (balise à cliquer en bas de l'écran)
Fench est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 12/01/2011, 20h43   #4
Membre actif
 
Homme David
Inscription : septembre 2007
Messages : 353
Détails du profil
Informations personnelles :
Nom : Homme David
Localisation : France

Informations professionnelles :
Secteur : Agroalimentaire - Agriculture

Informations forums :
Inscription : septembre 2007
Messages : 353
Points : 195
Points : 195
Citation:
Bonsoir,

Cad que tu veux un truc du genre:
Code :

$values = array(.., .., ..);
C'est exactement ça que je veux!!
damalaan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 12/01/2011, 21h07   #5
Membre Expert
 
Avatar de gene69
 
Inscription : janvier 2006
Messages : 951
Détails du profil
Informations personnelles :
Localisation : France

Informations professionnelles :
Secteur : High Tech - Produits et services télécom et Internet

Informations forums :
Inscription : janvier 2006
Messages : 951
Points : 1 063
Points : 1 063
si tu as du mal à t'en convaincre cree un petit script:
Code :
1
2
3
4
5
6
7
 
<?php
echo '<pre>';
$x = array("hjkkj",45465,"toto",5,-1, null,6);
print_r($x);
var_dump($x);
echo '</pre>';
Citation:
Envoyé par php
Array ( [0] => hjkkj [1] => 45465 [2] => toto [3] => 5 [4] => -1 [5] => [6] => 6 )
array(7) { [0]=> string(5) "hjkkj" [1]=> int(45465) [2]=> string(4) "toto" [3]=> int(5) [4]=> int(-1) [5]=> NULL [6]=> int(6) }
__________________
PHP fait nativement la validation d'adresse électronique Vous êtes perdu en PHP? rassurez-vous ici (en)
Utilisez le bouton résolu!
gene69 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/01/2011, 08h40   #6
Membre actif
 
Homme David
Inscription : septembre 2007
Messages : 353
Détails du profil
Informations personnelles :
Nom : Homme David
Localisation : France

Informations professionnelles :
Secteur : Agroalimentaire - Agriculture

Informations forums :
Inscription : septembre 2007
Messages : 353
Points : 195
Points : 195
ça ne me dit toujours pas comment transformer ça
Array ( [0] => 0901 [1] => 0902 [2] => 0903 [3] => 0904 [4] => 0905 )
en ça

Array(0901, 0902, 0903, 0904, 0905)
damalaan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/01/2011, 08h46   #7
Membre Expert
 
Avatar de ska_root
 
Homme
Développeur informatique
Inscription : août 2005
Messages : 1 179
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 42
Localisation : France

Informations professionnelles :
Activité : Développeur informatique
Secteur : Service public

Informations forums :
Inscription : août 2005
Messages : 1 179
Points : 1 580
Points : 1 580
Bonjour,

Tout le monde te dit que c'est la même chose...

Code :
1
2
3
4
5
6
7
8
9
10
11
12
 
<?php
$test= array(901,902,903,904,905);
$test2= array(0 => 901, 1 => 902, 2 => 903, 3 => 904, 4 => 905);
 
print_r($test);
echo "<hr/>";
print_r($test2);
 
$pareil= (!count(array_diff($test, $test2)))?"oui":"non";
echo "<h3>Les tableaux ont-ils les mêmes valeurs ? reponse : ".$pareil."</h3>";
?>
__________________
http://cdemarche.developpez.com/

Tu as la réponse à ta question ? N'oublies pas le petit en bas à gauche de ton message...
ska_root est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/01/2011, 09h32   #8
Membre actif
 
Homme David
Inscription : septembre 2007
Messages : 353
Détails du profil
Informations personnelles :
Nom : Homme David
Localisation : France

Informations professionnelles :
Secteur : Agroalimentaire - Agriculture

Informations forums :
Inscription : septembre 2007
Messages : 353
Points : 195
Points : 195
ok j'ai compris cette fois

bon alors mon souci c'est avec Artichow, je vais donc le forum qui va bien

merci
damalaan est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 23h17.


 
 
 
 
Partenaires

Hébergement Web