1
我怎么会去访问从Shopify JSON这些元素在PHP访问某些JSON元素
JSON:
{
"orders":[
{ "note_attributes":[
{
"name":"account_id",
"value":"[email protected]"
},
{
"name":"account_password",
"value":"xxxxxx"
},
{
"name":"security_answer",
"value":"xxxxxx"
}
],
这只是片断的对象。我如何访问每个值并将其分配给名称?例如,这个$ req ['account_id']将等于该名称标签的值。这是怎么我试图做到这一点,但它不工作:
foreach ($order['note_attributes'] as $attributes) {
$req = array();
$req[$attributes->name] = $attributes[$attributes->value];
}
我会再像回声$ REQ [“ACCOUNT_ID”]这将= [email protected]但它不工作有任何建议或修复?
尝试[json_decode](http://php.net/manual/en/function.json-decode.php),它会将json转换为php变量。 – Roopendra