foreach на json data php - PullRequest
       7

foreach на json data php

0 голосов
/ 03 июня 2018

Итак, у меня есть эти данные json (https://refdev.000webhostapp.com/GetLimiteds.php?userId=21709448), которые берут их отсюда, потому что они довольно большие.

И я хочу получить все имена Limited (которые находятся в массиве, называемомОграничения)

Теперь я пробовал такие вещи, как:

foreach($GetSeller['Limiteds'] as $mydata)
                        {
                            echo $mydata[0]['name'];
                        }     

, но отображались только 3 имени элемента.

1 Ответ

0 голосов
/ 03 июня 2018

@ alithedeveloper прав

<?php
$a = '{"TotalRAP":12143,"Limiteds":[[{"userAssetId":765806854,"serialNumber":null,"assetId":44113968,"name":"Kuddle E. Koala","recentAveragePrice":285,"originalPrice":null,"assetStock":null,"buildersClubMembershipType":0},{"userAssetId":800794372,"serialNumber":null,"assetId":15857936,"name":"Tee Vee","recentAveragePrice":659,"originalPrice":45,"assetStock":null,"buildersClubMembershipType":0},{"userAssetId":824837939,"serialNumber":542,"assetId":71499557,"name":"Slithering Slayer","recentAveragePrice":1287,"originalPrice":350,"assetStock":1100,"buildersClubMembershipType":0},{"userAssetId":837503419,"serialNumber":195,"assetId":73151254,"name":"Zombie Fiend","recentAveragePrice":1066,"originalPrice":300,"assetStock":800,"buildersClubMembershipType":0},{"userAssetId":880652082,"serialNumber":null,"assetId":76692214,"name":"Eggcognito Egg","recentAveragePrice":326,"originalPrice":null,"assetStock":null,"buildersClubMembershipType":0},{"userAssetId":880682344,"serialNumber":null,"assetId":76692866,"name":"Aqueous Egg of River Riding","recentAveragePrice":257,"originalPrice":null,"assetStock":null,"buildersClubMembershipType":0},{"userAssetId":1598993459,"serialNumber":null,"assetId":136217608,"name":"Golden Pilgrim Hat","recentAveragePrice":361,"originalPrice":null,"assetStock":null,"buildersClubMembershipType":0}],[],[],[{"userAssetId":762667052,"serialNumber":null,"assetId":20573078,"name":"Shaggy","recentAveragePrice":314,"originalPrice":null,"assetStock":null,"buildersClubMembershipType":0},{"userAssetId":2016591111,"serialNumber":null,"assetId":151786902,"name":"Neon Green Beautiful Hair","recentAveragePrice":6756,"originalPrice":null,"assetStock":null,"buildersClubMembershipType":0}],[],[],[],[],[{"userAssetId":1648048010,"serialNumber":null,"assetId":140469731,"name":"Festive Narwhal","recentAveragePrice":832,"originalPrice":null,"assetStock":null,"buildersClubMembershipType":0}],[]]}';

$GetSeller = json_decode($a, true);

foreach($GetSeller['Limiteds'] as $mydata){
    foreach($mydata as $mydatadata){
        echo $mydatadata['name'];
    }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...