获取数组php中的特定数据

时间:2018-11-28 15:35:17

标签: php arrays

我有这个数组:

Array
(
    [0] => stdClass Object
        (
            [MarketCurrency] => LTC
            [BaseCurrency] => BTC
            [MarketCurrencyLong] => Litecoin
            [BaseCurrencyLong] => Bitcoin
            [MinTradeSize] => 0.03039514
            [MarketName] => BTC-LTC
            [IsActive] => 1
            [IsRestricted] => 
            [Created] => 2014-02-13T00:00:00
            [Notice] => 
            [IsSponsored] => 
            [LogoUrl] => https://bittrexblobstorage.blob.core.windows.net/public/6defbc41-582d-47a6-bb2e-d0fa88663524.png
        )

    [1] => stdClass Object
        (
            [MarketCurrency] => DOGE
            [BaseCurrency] => BTC
            [MarketCurrencyLong] => Dogecoin
            [BaseCurrencyLong] => Bitcoin
            [MinTradeSize] => 462.96296296
            [MarketName] => BTC-DOGE
            [IsActive] => 1
            [IsRestricted] => 
            [Created] => 2014-02-13T00:00:00
            [Notice] => 
            [IsSponsored] => 
            [LogoUrl] => https://bittrexblobstorage.blob.core.windows.net/public/a2b8eaee-2905-4478-a7a0-246f212c64c6.png
        )

}

我将获得“ MarketCurrency”数据和“ BaseCurrency”数据。但是我不知道该怎么办。

我该怎么做?

我需要你的帮助。

1 个答案:

答案 0 :(得分:1)

您可以使用简单的foreach()来抓取对象。

foreach($data as $obj){
  echo "MarketCurrency = $obj->MarketCurrency and BaseCurrency = $obj->BaseCurrency".PHP_EOL;
}