PHP kullanarak aşağıdaki verileri ayrıştırmak için uğraşıyorum. Bir API onu döndürür ve çeşitli sözdizimlerini denedim. Verileri nesnel olmayan bir şekilde nasıl iade ederim? Veya, stdClass kullanarak verileri çağırmak için sözdizimi nedir?stdClass Nesnesi sorunları
Bunu bir veri tabanlı diziye dönüştürebilir miyim, hatta iki? Nesne tabanlı veri kümeleri olduğunda kayboluyorum.
stdClass Object
(
[0] => stdClass Object
(
[district] => stdClass Object
(
[state] => NY
[number] => 29
)
)
[1] => stdClass Object
(
[district] => stdClass Object
(
[state] => NY
[number] => 26
)
)
)
i var_dump yapmak sonra başıma nesne oluşturmak ve
, bu alın:object(stdClass)#8 (2) {
[0]=>
object(stdClass)#4 (1) {
["district"]=>
object(stdClass)#5 (2) {
["state"]=>
string(2) "NY"
["number"]=>
string(2) "29"
}
}
[1]=>
object(stdClass)#6 (1) {
["district"]=>
object(stdClass)#7 (2) {
["state"]=>
string(2) "NY"
["number"]=>
string(2) "26"
}
}
}
Bu nesne nereden geliyor? –
Bu API'den, http://emmense.com/sunlight-labs-php-library/ Php şunları içerir ('class.sunlightlabs.php'); $ sf = new SunlightDistrict; $ sf-> api_key = '[api key]'; echo '
'; ?> – ader