How can i innitialize each value returned from easypay array?

39 Views Asked by At

HELLO am using easypay payment API

<?php
//  $url = 'https://www.easypay.co.ug/api/';

i want to initialize each in its own variable and then save the them into a mysql table

I GOT THIS RESULT IN MY BROWSER FIREFOX

 {
    "details":{"phone":"256752950462","reference":"94","telecomId":"57650328142","transactionId":"811138","amount":"2000","reason":"Mobile Money Deposit. Phone: 256752950462 Amount: UGX 2,000 Charge: UGX 60 Amount Received: UGX 2,000 Date: 2021-07-19 20:56:22 TelecomID: 57650328142 TxID: 811138 Reason: Payment testings","currencyCode":"UGX"
             },
  "success":1,"data":"Mobile Money Deposit. Phone: 256752950462 Amount: UGX 2,000 Charge: UGX 60 Amount Received: UGX 2,000 Date: 2021-07-19 20:56:22 TelecomID: 57650328142 TxID: 811138 Reason: Payment testings"
 }

?>

Image for my result

1

There are 1 best solutions below

0
step On

For example this my code send request into some endpoint and return is processed by json_decode() function.

$token = 'some_token';
curl_setopt($url, CURLOPT_HTTPHEADER, array('Authorization: Token '.$token, 'Access-Control-Allow-Origin: *'));
curl_setopt($request, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, false);

$response = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_HTTP_CODE);
http_response_code($status);
curl_close($request);
$data = json_decode($response, true);
if($data) {
    // process $data as array
}