我试图在循环中用子阵列填充数组。在每次迭代中都必须有一个array_push,在循环后我想保存数组。该数组必须如下所示:
Array => (
"pa_attribute1" => Array(
'name' => 'pa_attribute1',
'value' => 'value',
'is_visible' => '1',
'is_taxonomy' => '1'
),
"pa_attribute2" => Array(
'name' => 'pa_attribute2',
'value' => 'value',
'is_visible' => '1',
'is_taxonomy' => '1'
),
"pa_attribute3" => Array(
'name' => 'pa_attribute3',
'value' => 'value',
'is_visible' => '1',
'is_taxonomy' => '1'
),
)
问题'是,key的名称是变量。所以," pa_attribute1," pa_attribute2"等等,是功能的结果,我不知道'结果,所以我不能编程所有的可能性。 是否有一个函数可用于创建一个变量为键的新数组?喜欢这个?
$result = array();
for($i=0; $1 < $length; $i++){
$value = get_attribute_name();
$value = Array();
array_push($result, [array]);
}
print_r($result);
答案 0 :(得分:4)
您不需要select T1.DOC, T1.REV, T1.NME, T1.TISU, T2.TRET
from (
select T1.DOC, T1.REV, T1.NME, SUM(T1.ISU) as TISU
from T1
group by T1.DOC, T1.REV, T1.NME
) as T1
left join (
select T2.DOC, T2.REV, T2.NME, SUM(T2.RET) as TRET
from T2
group by T2.DOC, T2.REV, T2.NME
) as T1
on T1.DOC = T2.DOC
and T1.REV = T2.REV
and T1.NME = T2.NME
,您可以直接添加元素:
array_push()