如何为$ wpdb-> insert创建一个包含column => value对的数组
16lz
2021-01-22
I have an array that looks like:
我有一个看起来像这样的数组:
Array ( [0] => Array ( [0] => enrolment_id [1] => 0123)
[1] => Array ( [0] => child_first [1] => Kate )
[2] => Array ( [0] => child_last [1] => Limmage )
[3] => Array ( [0] => child_preferred [1] => )... )
etc... all the way to [159]. It comes from $_POST data.
等等......一直到[159]。它来自$ _POST数据。
How do I get this to look like
我该如何看待它
'enrolment_id' => '0123',
'child_first' => 'Kate',
'child_last' => 'Limmage',
so that I can use it in the from $wpdb->insert( $table, $data, $format );
所以我可以在$ wpdb-> insert($ table,$ data,$ format)中使用它;
1 个解决方案
#1
1
The easiest way:
最简单的方法:
$result = array();
foreach ($_POST as $v) {
$result[$v[0]] = $v[1];
}
更多相关文章
- 如何在php中为json数组创建搜索功能
- PHP数组值进入第二个数组[重复]
- 如何在php数组中插入新的键值对?
- mysql_fetch_array返回一个数组,数字为“1”
- PHP-从多维数组中删除重复值
- 更改数组键而不更改顺序
- 在PHP中更改关联数组索引的位置
- 如何在数组中存储产品数量
- php吧字符串直接转换成数组处理