我有下面的数据数组,我需要使用单个foreach函数循环它。 我需要[A],[B]等作为键,将其值作为值。
我该怎么做
[data] => Array
(
[0] => Array
(
[A] => TestCompany1
[B] => testcompany1
[C] => fle
[D] => subscription
[E] => google.com
)
[1] => Array
(
[A] => TestCompany2
[B] => testcompany2
[C] => eid
[D] => subscription
[E] => google.com
)
)
我需要在没有使用多个foreach的情况下放弃(就像我现在正在使用的那样)
foreach($row['data'] as $key => $val) {
foreach($val as $key1 => $val1) {
$field = $val1;
}
}
由于
答案 0 :(得分:0)
你可以这样试试:
config.dsl().insertInto(Tables.myTable)
.set(Tables.myTable.myText, inputText)
.execute();
config.dsl().select.currval('myTableName_myColumnName_seq')
.from myTable;
答案 1 :(得分:0)
让我猜猜你需要什么。结果如下:
A = [TestCompany1, TestCompany2]
B = [testcompany1, testcompany2]
C = [fle, eid]
D =>subscription
E =>google.com
说:
$array[0] = array(
'A'=>'TestCompany1',
'B'=>'testCompany1',
'C'=>'fle',
'D'=>'subscription',
'E'=>'google.com'
);
$array[1] = array(
'A'=>'TestCompany2',
'B'=>'testCompany2',
'C'=>'eid',
'D'=>'subscription',
'E'=>'google.com'
);
您可以使用: $ result = array_merge_recursive($ array [0],$ array [1]); 然后转换或$ result。
答案 2 :(得分:0)
我使用以下代码实现了这一目标。
$data = array();
foreach($row['data'] as $val) {
$data['field1'][] = $val['A'];
$data['field2'][] = $val['B'];
$data['field3'][] = $val['C'];
$data['field4'][] = $val['D'];
$data['field5'][] = $val['E'];
}
我使用单个foreach函数。