Jump to content

how to get specific data using curl


sakhi

Recommended Posts

I have json code  and i want to prine only {"currency":"DOGE","available":"0","reserved":"420.000000000"} data.

my json data

[{"currency":"1ST","available":"0","reserved":"0"},{"currency":"DOGE","available":"0","reserved":"420.000000000"},{"currency":"ZSC","available":"0","reserved":"0"}]    

I use this code

 <?php
  $ch = curl_init('http://arbitrage.adquash.com/balance.json'); 
 curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json'));
 $return = curl_exec($ch); 
  curl_close($ch); 
$result=json_decode($return);
echo "<pre>";
foreach($result as $row){
  echo $row->$a['currency']['available']['reserved'];

?>

Link to comment
Share on other sites

echo $row->$a['currency']['available']['reserved'];

I don't know where you're getting "$a" from but it doesn't belong there.

If you print_r($row) you'll see what the value is. It's an object with "currency", "available", and "reserved" properties. Like any other object, you access them like ->currency.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.