Afficher une variable PHP

  • Auteur de la discussion Auteur de la discussion rasheed
  • Date de début Date de début
Nouveau WRInaute
Bonjour

Le resultat affiché d'une variable print_r($tableau); sur mon script donne ceci :

Code:
Array ( [TTI_transmission] => Array ( [quoteresult] => Array ( [0] => Array ( [symbolfound] => 1 [tickersymbol] => $DJI [companyname] => DOW JONES INDUSTRIAL AVERAGE [last] => 12560.20 [change] => +30.15 [pcthange] => +0.24 [volume] => 164,930,779 ) [1] => Array ( [symbolfound] => 1 [tickersymbol] => SPX [companyname] => STANDARD AND POORS 500 INDEX [last] => 1443.76 [change] => +4.39 [pcthange] => +0.30 [volume] => 0 ) [2] => Array ( [symbolfound] => 1 [tickersymbol] => TSEA.CA [companyname] => S&P/TSX COMPOSITE INDEX [last] => 13425.02 [change] => -23.29 [pcthange] => -0.17 [volume] => 0 ) [3] => Array ( [symbolfound] => 1 [tickersymbol] => JX.CA [companyname] => S&P/TSX VENTURE COMPOSITE [last] => 3257.43 [change] => +16.46 [pcthange] => +0.51 [volume] => 0 ) [4] => Array ( [symbolfound] => 1 [tickersymbol] => /GC7J [companyname] => GOLD APRIL [last] => 674.20 [change] => +2.10 [pcthange] => +0.31 [volume] => 1,718 ) [5] => Array ( [symbolfound] => 1 [tickersymbol] => /SI7J [companyname] => SILVER APRIL [last] => 13.694 [change] => +0.124 [pcthange] => +0.91 [volume] => 0 ) [6] => Array ( [symbolfound] => 1 [tickersymbol] => /CL7K [companyname] => CRUDE OIL LT SWEET MAY NT [last] => 63.94 [change] => -0.34 [pcthange] => -0.53 [volume] => 180,648 ) [7] => Array ( [symbolfound] => 1 [tickersymbol] => /NG7K [companyname] => HENRY HUB NAT GAS MAY NT [last] => 7.625 [change] => +0.018 [pcthange] => +0.24 [volume] => 35,260 ) [8] => Array ( [symbolfound] => 1 [tickersymbol] => /HG7J [companyname] => COPPER APRIL [last] => 3.371 [change] => -0.0115 [pcthange] => -0.34 [volume] => 304 ) [9] => Array ( [symbolfound] => 1 [tickersymbol] => /PL7J [companyname] => PLATINUM APRIL NT [last] => 1261.00 [change] => -1.90 [pcthange] => -0.15 [volume] => 24 ) [10] => Array ( [symbolfound] => 1 [tickersymbol] => /PA7J [companyname] => PALLADIUM APRIL NT [last] => 0.00 [change] => 0.00 [pcthange] => 0.00 [volume] => 0 ) [11] => Array ( [symbolfound] => 1 [tickersymbol] => /QL7K [companyname] => COAL MAY NT [last] => 41.25 [change] => 0.00 [pcthange] => 0.00 [volume] => 0 ) ) [datestamp] => Friday, April 6, 2:01 PM ) )

Or, l'information que je cherche à afficher dans tout ce code est celle en 10ème ligne "674.20" :?

Merci de votre aide :wink:
 
Nouveau WRInaute
ah je viens de tester :D
L'affichage s'amèliore mais ce n'est toujours pas ce que je cherche :D, je veux afficher rien que "674.20" (qui se trouve sur [4] => Array).
Comment puis je tirer cette information depuis tout ce code !


--------------------------------------------------------
Array
(
[TTI_transmission] => Array
(
[quoteresult] => Array
(
[0] => Array
(
[symbolfound] => 1
[tickersymbol] => $DJI
[companyname] => DOW JONES INDUSTRIAL AVERAGE
[last] => 12560.20
[change] => +30.15
[pcthange] => +0.24
[volume] => 164,930,779
)

[1] => Array
(
[symbolfound] => 1
[tickersymbol] => SPX
[companyname] => STANDARD AND POORS 500 INDEX
[last] => 1443.76
[change] => +4.39
[pcthange] => +0.30
[volume] => 0
)

[2] => Array
(
[symbolfound] => 1
[tickersymbol] => TSEA.CA
[companyname] => S&P/TSX COMPOSITE INDEX
[last] => 13425.02
[change] => -23.29
[pcthange] => -0.17
[volume] => 0
)

[3] => Array
(
[symbolfound] => 1
[tickersymbol] => JX.CA
[companyname] => S&P/TSX VENTURE COMPOSITE
[last] => 3257.43
[change] => +16.46
[pcthange] => +0.51
[volume] => 0
)

[4] => Array
(
[symbolfound] => 1
[tickersymbol] => /GC7J
[companyname] => GOLD APRIL
[last] => 674.20
[change] => +2.10
[pcthange] => +0.31
[volume] => 1,718
)

[5] => Array
(
[symbolfound] => 1
[tickersymbol] => /SI7J
[companyname] => SILVER APRIL
[last] => 13.694
[change] => +0.124
[pcthange] => +0.91
[volume] => 0
)

[6] => Array
(
[symbolfound] => 1
[tickersymbol] => /CL7K
[companyname] => CRUDE OIL LT SWEET MAY
[last] => 64.28
[change] => -0.10
[pcthange] => -0.15
[volume] => 1,188
)

[7] => Array
(
[symbolfound] => 1
[tickersymbol] => /NG7K
[companyname] => HENRY HUB NAT GAS MAY
[last] => 7.607
[change] => +0.092
[pcthange] => +1.22
[volume] => 750
)

[8] => Array
(
[symbolfound] => 1
[tickersymbol] => /HG7J
[companyname] => COPPER APRIL
[last] => 3.371
[change] => -0.0115
[pcthange] => -0.34
[volume] => 304
)

[9] => Array
(
[symbolfound] => 1
[tickersymbol] => /PL7J
[companyname] => PLATINUM APRIL NT
[last] => 1261.00
[change] => -1.90
[pcthange] => -0.15
[volume] => 24
)

[10] => Array
(
[symbolfound] => 1
[tickersymbol] => /PA7J
[companyname] => PALLADIUM APRIL NT
[last] => 0.00
[change] => 0.00
[pcthange] => 0.00
[volume] => 0
)

[11] => Array
(
[symbolfound] => 1
[tickersymbol] => /QL7K
[companyname] => COAL MAY NT
[last] => 41.25
[change] => 0.00
[pcthange] => 0.00
[volume] => 0
)

)

[datestamp] => Friday, April 6, 3:45 PM
)

)
----------------------------------------------------------

Merci
 
WRInaute accro
j'ai pas eu le courage de tester :p Avec un tableau aussi énorme ^^
et avec les cotes ? $tableau[4]['last'] marche pas non pu ? lol
 
WRInaute accro
Si tu donnais le code et non le résultat ;) on pourrait tester :D
j'ai pas trop envie de mettre des ; partout :D
 
WRInaute passionné
Code:
echo '<pre><b>TTI_transmission</b><br>';
print_r($tableau['TTI_transmission']);
echo '<br><br><b>TTI_transmission / quoteresult</b><br>';
print_r($tableau['TTI_transmission']['quoteresult']);
echo '</pre>';

bon ben, qu'est-ce que ça affiche?
 
Nouveau WRInaute
phpmikedu83 a dit:
et:

Code:
echo $tableau['TTI_transmission']['quoteresult'][4]['last'];

C'est pas mieux?...

phpmikedu83, je pense que vous avez édité votre message, au moment ou je répondais, votre code proposé étais $tableau[4]['last'] et c'est à ce message que je voulais répondre comme quoi ça n'a pas marché :)

Maintenant pour echo $tableau['TTI_transmission']['quoteresult'][4]['last']; ça maaaaaaarche.

YoyoS, phpmikedu83, merci mille et une fois :wink:
 
Nouveau WRInaute
Rebonjour les amis

J'ai cette fois le code ci-dessous et j'aimerai sortir la valeur 8,3338. J'ai essayé cela echo $tableau_php['Currency']['Observation']['Currency_name'][1]; mais ça na pas marché !


Code:
Array
(
    [Currency] => Array
        (
            [xmlns] => http://www.w3.org/2001/XMLSchema-instance
            [Observation] => Array
                (
                    [Currency_name] => Array
                        (
                            [Observation_date] => 			2007-04-05
                            [Observation_data] => Array
                                (
                                    [0] => 			8,33
                                    [1] => 			8,3338
                                    [2] => 			0,1200
                                )

                        )

                )

        )

)
:wink:
 
WRInaute passionné
Parce que c'est avec:

Code:
$tableau_php['Currency']['Observation']['Currency_name']['Observation_data'][1]

Que tu y arriveras mieux...

Mais t'as vraiment besoin de tant de dimensions dans tes tableaux?
C'est énorme quand même! :lol:
 
Discussions similaires
Haut