opened
andibastian
username_0
can i use array for symbol in $api->ticker() ?
Websocket $api->ticker array
issue
closed
jaggedsoft
username_1
issue
created
jaggedsoft
username_1
```php
$api->ticker("BNBBTC", function($api, $symbol, $ticker) {
	print_r($ticker);
});
```
comment
created
jaggedsoft
username_1
No, this function accepts `false` as the first parameter and it will return data for all symbols. Otherwise it will return only one at a time
comment
created
njghamdi
username_2
Hi Bro, 

this and all other websocket functions only show result if you print it as an array ( print_r),  
but does not  work if you print only some elements ( such as $ticker->element ) , any suggestion to get an element without print_r ?
comment
created
jaggedsoft
username_1
use it like an array `$ticker['element'];` cheers bro
comment
created
njghamdi
username_2
Thanks boss for the great job and quick response. I'm using this 

$api->ticker(false, function($api, $symbol, $ticker) {
//	print_r($ticker);
	echo $ticker['symbol'] . "     |        "  . $ticker['quoteVolume']  ;
	echo "<hr>";
});
 but it does not show any result, if I uncommented "print_r($ticker)" all works fine! Isn't possible to show up the result without a need to print_r first?
comment
created
jaggedsoft
username_1
`$ticker[$symbol]` my friend, and `$ticker[$symbol]['quoteVolume']`
comment
created
njghamdi
username_2
Unfortunately, does not work either. I got those notice errors 

PHP Notice:  Undefined index: ETHBTC on line 38
PHP Notice:  Undefined index: LTCBTC on line 38
PHP Notice:  Undefined index: LTCBTC on line 38
PHP Notice:  Undefined index: BNBBTC on line 38
PHP Notice:  Undefined index: BNBBTC on line 38
PHP Notice:  Undefined index: NEOBTC on line 38

and nothing show on the browser as well.
comment
created
jaggedsoft
username_1
So you need to loop through the array that's returned when you pass `false` as the first parameter, because each object is sent from binance like this:
```
Array
(
    [eventType] => 24hrTicker
    [eventTime] => 1552061024363
    [symbol] => OSTETH
    [priceChange] => 0.00001316
    [percentChange] => 7.565
    [averagePrice] => 0.00018461
    [prevClose] => 0.00017491
    [close] => 0.00018713
    [closeQty] => 6130.00000000
    [bestBid] => 0.00018617
    [bestBidQty] => 21664.00000000
    [bestAsk] => 0.00018704
```

```php
require 'vendor/autoload.php';
$api = new Binance\API('','');
$api->ticker(false, function($api, $symbol, $ticker) {
	echo "{$ticker['symbol']}: {$ticker['close']}\n";
});
```
comment
created
njghamdi
username_2
Wow, finally I got it works. 
Appreciate it all, you are the hero. Thank you very much.
comment