stdClass Object
(
[net_type] => Net 1
[No of Windows] => 2
[0] => stdClass Object
(
[Windows1] => stdClass Object
(
[Width1] => 20
[Height1] => 10
)
[Windows2] => stdClass Object
(
[Width2] => 40
[Height2] => 15
)
)
[Pricing/sq ft] => 20
[Total Area] => 2
[Total Price] => 5
)
我知道要获得net_type
的价值:
$details_decode = json_decode($details);
echo "details==".$details_decode->net_type;
但是如何获得Width1
的价值,即:
echo "windows 1==".$details_decode->Windows1['Width1'];
答案 0 :(得分:1)
您可能最好使用true
传递第二个json_decode
)参数:
当为TRUE时,返回的对象将被转换为关联数组。
即:
$details_decode = json_decode($details, true);
然后像数组一样访问它,这是更好的,因为一些对象属性中有空格。 e.g:
$details_decode['net_type']
$details_decode[0]['Windows1']
$details_decode['Pricing/sq ft']
希望这有帮助。