我有一个这样的数组
array(12) {
[0]=> string(1) "3"
[1]=> string(1) "3"
[2]=> string(1) "5"
[3]=> string(1) "3"
[4]=> string(1) "4"
[5]=> string(1) "3"
[6]=> string(1) "3"
[7]=> string(1) "3"
[8]=> string(1) "2"
[9]=> string(1) "3"
[10]=> string(1) "2"
[11]=> string(1) "3"
}
数组是动态的,所以数组的值可以随时改变
我也有一个mysql表,结构是这样的
|id|bobot_c1|bobot_c2|bobot_c3|bobot_c4|bobot_c5|bobot_c6|bobot_c7|bobot_c8|bobot_c9|bobot_c10|bobot_c11|bobot_c12|
-------------------------------------------------------------------------------------------------------------------
| | | | | | | | | | | | | |
-------------------------------------------------------------------------------------------------------------------
id 为auto_increment
如何将键数组:"3"、"3"、"5"、"3"
等输入到数据库表中?
所以对于值 index [0],我进入 bobot_c1 列,index [1],进入 bobot_c2 专栏等。
谢谢!
最佳答案
像这样创建另一个数组:
$dataArray = (
'bobot_c1' => $array[0],
'bobot_c2' => $array[1],
'bobot_c3' => $array[2],
'bobot_c4' => $array[3],
.
.
.
);
类似地添加更多列并将 $dataArray 插入数据库。
关于php - codeigniter:如何将数组的值放入特定的表列中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30409731/