[RESOLU] récuperer une variable dans un array

Petit nouveau ! | 6 Messages

22 mai 2020, 09:31

Bonjour,
Les tableaux, c'est pas mon truc lol :

j'affiche ce tableau avec cette fonction :

echo var_dump(json_decode($json_response, TRUE));


J'aimerai récupérer cette variable dans cet array : (tr62b466ac9bbf88ff5d44b7ad6e23d237)

array(4) { ["success"]=> bool(true) ["message"]=> string(0) "" ["code"]=> int(0) ["data"]=> array(18) { ["id"]=> string(34) "tr62b466ac9bbf88ff5d44b7ad6e23d237" ["orderId"]=> string(7) "CDB-149" ["amount"]=> int(9000) ["currency"]=> string(3) "EUR" ["type"]=> string(4) "CASH" ["paymentType"]=> string(2) "CB" ["url"]=> string(78) "22585" ["testMode"]=> int(1) ["result"]=> array(3) { ["status"]=> string(7) "PENDING" ["threeDSecureStatus"]=> NULL ["paymentErrorStatus"]=> string(0) "" } ["card"]=> array(3) { ["number"]=> string(0) "" ["expiration"]=> string(0) "" ["country"]=> string(0) "" } ["buyer"]=> array(7) { ["id"]=> string(9) "123654789" ["lastName"]=> string(9) "votre_nom" ["firstName"]=> string(12) "votre_prenom" ["email"]=> string(19) "email" ["country"]=> string(0) "" ["ipAddress"]=> string(13) "217.160.6.140" ["companyName"]=> string(13) "votre_societe" } ["metadata"]=> NULL ["eligibleAmount"]=> NULL ["idFingerprint"]=> int(0) ["createdAt"]=> string(25) "2020-05-22T09:24:47+02:00" ["valueAt"]=> string(25) "2020-05-22T09:24:47+02:00" ["answeredAt"]=> int(0) ["ttl"]=> string(1) "0" } }

En vous remerciant

Mammouth du PHP | 1967 Messages

22 mai 2020, 10:01

<?php
$tableau  = json_decode($json_response, TRUE);
$id = $tableau['data']['id'];
var_dump($id);
?>
Spols
pour les fan de rubik's cube ou pour les curieux ==> le portail francophone du rubik's cube

Petit nouveau ! | 6 Messages

22 mai 2020, 10:17

Merci !!!!