这种结构如何分解写入数据库?需要具体代码
Array
(
[items] => Array
(
[@attributes] => Array
(
[list] => true
) [item] => Array
(
[0] => Array
(
[cid] => 50011988
[delist_time] => 2010-08-12 15:53:40
[iid] => af91e63475c0eecd2f1f8863b42a5686
[location] => Array
(
[city] => 广州
[state] => 广东
) [nick] => 啊啊
[num_iid] => 5031811796
[post_fee] => 8.00
[price] => 19.90
[title] => aaa 洁面
[type] => fixed
) [1] => Array
(
[delist_time] => 2010-08-12 11:32:55
[iid] => 337d419e07f797e624e1962c336663b0
[location] => Array
(
[city] => 广州
[state] => 广东
) [nick] => aaa
[post_fee] => 8.00
[price] => 9.90
[title] => ffff2折
[type] => fixed
) [2] => Array
(
[delist_time] => 2010-08-12 11:32:55
[iid] => 3a10e8263adf6c3a4329ad4ce0bf27d0
[location] => Array
(
[city] => 广州
[state] => 广东
) [nick] => aaaaa
[post_fee] => 8.00
[price] => 21.00
[title] => ffff高效控油 水嫩清新 6折
[type] => fixed
) ) ) [total_results] => 178
)
Array
(
[items] => Array
(
[@attributes] => Array
(
[list] => true
) [item] => Array
(
[0] => Array
(
[cid] => 50011988
[delist_time] => 2010-08-12 15:53:40
[iid] => af91e63475c0eecd2f1f8863b42a5686
[location] => Array
(
[city] => 广州
[state] => 广东
) [nick] => 啊啊
[num_iid] => 5031811796
[post_fee] => 8.00
[price] => 19.90
[title] => aaa 洁面
[type] => fixed
) [1] => Array
(
[delist_time] => 2010-08-12 11:32:55
[iid] => 337d419e07f797e624e1962c336663b0
[location] => Array
(
[city] => 广州
[state] => 广东
) [nick] => aaa
[post_fee] => 8.00
[price] => 9.90
[title] => ffff2折
[type] => fixed
) [2] => Array
(
[delist_time] => 2010-08-12 11:32:55
[iid] => 3a10e8263adf6c3a4329ad4ce0bf27d0
[location] => Array
(
[city] => 广州
[state] => 广东
) [nick] => aaaaa
[post_fee] => 8.00
[price] => 21.00
[title] => ffff高效控油 水嫩清新 6折
[type] => fixed
) ) ) [total_results] => 178
)
不太清楚不规则的 结构如何读取,还是有直接能读取到 item 处的方法?
具体几个嵌套要看你最终要什么样的数据结构了。如果你只是为了保存这个数组,下次能从数据查询出来继续使用的话,
你可以直接
$insertString = json_encode($array);
//将$insertString存入数据库
用的时候取出来。
$array = json_decode($dbString,true);