tf-redfree / PHP-btce-api

BTC-e API Class
MIT License
44 stars 41 forks source link

Simple balance request? #11

Closed mignav closed 6 years ago

mignav commented 6 years ago

When I run your code I got this:

Array ( [success] => 1 [return] => Array ( [funds] => Array ( [usd] => 0

... etc.

But how I can get only that "[usd]" parameter, as value ($usdbalance) , like

<? somecode Array ( [usd] etc. -> echo $usdbalance; ?>

how? Thank you so much!

tf-redfree commented 6 years ago

Hi mignav,

It sounds like you're new to PHP, welcome! Simply, you can assign that array to a variable, then use the keys to lookup the item.

In a more detailed manor, you can follow these steps: For example if that Array ( [success]... ) etc was assigned to $result: $result = $Api->apiQuery(...your params...); then you could access the usd by following the keys down, in this case: [return], then [funds] then [usd].

You could therefore get a variable called $usdbalance like this: $usdbalance = $result['return']['funds']['usd']; You could then use this to variable to print out (echo $usdbalance) as in your question.

These are called associative arrays in PHP, some more information about these can be found here: http://php.net/manual/en/language.types.array.php and https://www.w3schools.com/php/php_arrays.asp

Cheers, Tony

mignav commented 6 years ago

Dear Tony,

Yea, I am new in PHP for sure, but your code $usdbalance = $result['return']['funds']['usd']; does not work. And echo $usdbalance; code didn't returned anything. Anyway, you understand perfectly what I need, now just if you can please provide me a valid PHP code for it! Thank you so much.

tf-redfree commented 6 years ago

Hi mignav,

In your original question what is the name of the variable that you are using var_dump/print_r to get the output: "Array ( [success] => 1 [return] => Array ( [funds] => Array ( [usd] => 0..."?

Tony

mignav commented 6 years ago

Dear Tony,

I am asking regarding your code here in PHP repository named "PHP-btce-api". I am getting that otput when I load Example.php from that your repository, and I need to know how to get only [usd] parameter from array? So, when I write in PHP echo $usdbalance; it have to return me a proper my account balance value, but I don't know how? How to make echo $usdbalance; to return a proper valid value from my account?

tf-redfree commented 6 years ago

Hi mignav,

Is btc-e still online? I get an FBI warning when I try to get onto it. It may not currently be possible?

Tony

mignav commented 6 years ago

No, not online but Wex.nz is online. I used this code there. Why you closed this thread?