我有这个解码的JSON,想在我的视图中显示数据,但我得到了
ErrorException(E_ERROR) 未定义的索引:streetNumber
以下是数据样本:
array(11) {
[0] => array(26) {
["privateRemarks"] => string(98)
"Please use showing time and *** is available for any questions regarding showings at 00000" ["property"] => array(40) {
["roof"] => NULL["cooling"] => string(27)
"Central Cooling,Paddle Fans" ["style"] => string(8)
"Detached" ["area"] => NULL["bathsFull"] => int(5)["bathsHalf"] => int(1)["stories"] => NULL["fireplaces"] => NULL["flooring"] => string(13)
"Marble Floors" ["heating"] => string(26)
"Central Heat,Electric Heat" ["bathrooms"] => string(4)
"6.00" ["foundation"] => NULL["laundryFeatures"] => NULL["occupantName"] => NULL["ownerName"] => NULL["lotDescription"] => string(22)
"Less Than 1/4 Acre Lot" ["pool"] => string(17)
"Below Ground Pool" ["subType"] => NULL["bedrooms"] => int(5)["interiorFeatures"] => string(18)
"Second Floor Entry" ["lotSize"] => string(6)
"55x127" ["areaSource"] => NULL["maintenanceExpense"] => NULL["additionalRooms"] => string(38)
"Family Room,Other,Utility Room/Laundry" ["exteriorFeatures"] => string(35)
"High Impact Doors,Exterior Lighting" ["water"] => string(15)
"Municipal Water" ["view"] => string(25)
"Ocean View,Pool Area View" ["lotSizeArea"] => int(55)["subdivision"] => NULL["construction"] => string(16)
"CBS Construction" ["parking"] => array(3) {
["leased"] => NULL["spaces"] => NULL["description"] => string(8)
"Driveway"
}["lotSizeAreaUnits"] => NULL["type"] => string(3)
"RES" ["garageSpaces"] => int(2)["bathsThreeQuarter"] => NULL["accessibility"] => NULL["acres"] => NULL["occupantType"] => string(18)
"Call Listing Agent" ["subTypeText"] => NULL["yearBuilt"] => int(2006)
}["mlsId"] => int(000000)["terms"] => NULL["showingInstructions"] => NULL["office"] => array(4) {
["contact"] => array(3) {
["email"] => NULL["office"] => string(12)
"000000000" ["cell"] => NULL
}["name"] => string(15)
"**********" ["servingName"] => string(15)
"**********" ["brokerid"] => string(6)
"*****"
}["leaseTerm"] => NULL["disclaimer"] => string(66)
"This information is believed to be accurate, but without warranty." ["address"] => array(10) {
["crossStreet"] => NULL["state"] => string(2)
"FL" ["country"] => string(13)
"United States" ["postalCode"] => string(5)
"33304" ["streetName"] => string(28)
"N Fort Lauderdale Beach Blvd" ["streetNumberText"] => string(4)
"00000" ["city"] => string(15)
"Fort Lauderdale" ["streetNumber"] => int(0000)["full"] => string(33)
"******* Beach Blvd" ["unit"] => NULL
}["agreement"] => string(28)
"Exclusive Right to Sell/Rent" ["listDate"] => NULL["agent"] => array(4) {
["lastName"] => string(8)
"******" ["contact"] => array(3) {
["email"] => string(16)
"***********" ["office"] => string(12)
"******" ["cell"] => NULL
}["firstName"] => string(6)
"*****" ["id"] => string(7)
"******"
}["modified"] => string(24)
"2018-04-01T08:27:17.903Z" ["school"] => NULL["photos"] => array(65) {
[0] => string(168)
"img.jpg" [1] => string(168)
}["listPrice"] => int(00005000)["listingId"] => string(9)
"*******" ["mls"] => array(6) {
["status"] => string(6)
"Active" ["area"] => string(4)
"3160" ["daysOnMarket"] => NULL["originatingSystemName"] => NULL["statusText"] => string(6)
"Active" ["areaMinor"] => NULL
}["geo"] => array(5) {
["county"] => string(14)
"Broward County" ["lat"] => NULL["lng"] => NULL["marketArea"] => string(4)
"31" ["directions"] => NULL
}["tax"] => array(3) {
["taxYear"] => int(2017)["taxAnnualAmount"] => int(41)["id"] => string(12)
"494331"
}["coAgent"] => NULL["sales"] => NULL["leaseType"] => NULL["virtualTourUrl"] => string(56)
"https://www.prop.com" ["remarks"] => string(65)
"4 levels of your estate." ["association"] => array(3) {
["fee"] => int(0)["name"] => string(10)
"Homeowners" ["amenities"] => NULL
}
}
}
这里是Controller摘录
$properties = json_decode($file, true);
return view('properties.all-properties')->with('properties',$properties);
以下是我视图中的测试
@foreach($properties as $details)
{{ $details["streetNumber"] }}
@endforeach
我想通过数据循环构建列表信息
答案 0 :(得分:1)
a = 1/2 b * h
位于streetNumber
内。
理想情况下应该是
address
将来,如果您遇到这样的问题,您的第一步就是打印@foreach($properties as $details)
{{ $details["address"]["streetNumber"] }}
@endforeach
并查看其中的内容。
Stackoverflow用于通用问题和解决方案。您还可以在Google上复制粘贴错误,并了解错误发生的原因。