我觉得这很难!只有专家吗?
好的,我有一些变量(从get_defined_vars返回):
Array
(
[lead] => Array
(
[2] => fstory
[4] => him
[5] => trtr
[1] => 508b38ee02f502.23680245.png
)
[form] => Array
(
[id] => 3
)
[fields] => Array
(
[0] => Array
(
[adminLabel] => formname
[id] => 2
)
[1] => Array
(
[adminLabel] => hisher
[id] => 4
[2] => Array
(
[adminLabel] => fname
[id] => 5
)
[3] => Array
(
[adminLabel] => sign
[id] => 1
)
)
我需要将数组字段键设为[fields] [adminLabel]
,将值设为[lead] [#]
。
因此,在此示例中,数组将具有key = value
formname = fstory
fname = trtr
hisher = his
sign = 508b38ee02f502.23680245.png
有道理吗?可能的?
答案 0 :(得分:1)
试试这个。这是未经测试的。
$result_values = $array['lead'];
$results = array();
foreach ($array['form']['fields'] as $value) {
if (is_array($value)) {
$results[$value['adminLabel']] = $result_values[$value['id']];
}
}
print_r($results);