【发布时间】:2015-05-05 13:01:30
【问题描述】:
我有数组(从数据库返回),看起来像这样:
response = {
0 = {
id = "12312132",
title = "title1",
....
createDT = "2015-03-03 22:53:17"
}
1 = {
id = "456456456",
title = "title2",
....
createDT = "2015-03-03 22:53:17"
}
2 = {
id = "789789789",
title = "title3",
....
createDT = "2015-03-03 22:53:17"
}
}
我需要像这样在字典中使用 php 转换它:
response = {
"12312132" = {
title = "title1",
....
createDT = "2015-03-03 22:53:17"
}
"456456456" = {
title = "title2",
....
createDT = "2015-03-03 22:53:17"
}
"789789789" = {
title = "title3",
....
createDT = "2015-03-03 22:53:17"
}
}
即key 是 id。或许php中有一些函数,方便吗?
【问题讨论】:
标签: php arrays dictionary