-1
我有这样连接两个指标值在每个
$rr=array();
foreach($relations as $key=>$type){
$rr[$relationType->U2U_Related_USR_ID]=$type[$k]->MSTT_Name.'/'.$type[$k+1]->MSTT_Name;
$k++;
}
上午只得到第一指标值的循环。如何为每个连接两个索引值。
我有这样连接两个指标值在每个
$rr=array();
foreach($relations as $key=>$type){
$rr[$relationType->U2U_Related_USR_ID]=$type[$k]->MSTT_Name.'/'.$type[$k+1]->MSTT_Name;
$k++;
}
上午只得到第一指标值的循环。如何为每个连接两个索引值。
增加!
$rr = array();
for ($i = 0, $n = count($type); $i < $n; $i += 2) {
$t1 = $type[$i];
$t2 = $type[$i + 1];
$rr[$relationType->U2U_Related_USR_ID] = $t1->MSTT_Name.'/'.$t2->MSTT_Name;
}
注:$type
的长度应为偶数!
你可以用两对夫妇键/值你的工作循环内是这样的:
foreach($relations as $key=>$type){
list($odd_key, $odd_value) = each($relations);
//... your code here
// This work with a step by 2 elements. If you need step by 1,
// add the following line at the end of the loop :
//prev($relations)
}
目前尚不清楚哪些指标应该是什么值应为。请举例说明索引中应连接的内容。 –
**请审核并批准答案。** – Florent