日期:2014-05-16 浏览次数:20592 次
<?php
$id = array(8,31,32);
$resarr = array();
foreach($id as $num)
{
$product = array(
array(
'pid'=>'10',
'name'=>'产品1'
),
array(
'pid'=>'11',
'name'=>'产品2'
)
);
foreach($product as $key => $value)
{
$result_value = "";
foreach($value as $k => $v)
{
$result_value .= $result_value ? "|" : "";
$result_value .= $v['pid'];
}
$product[$key]['value'] = $result_value;
}
$resarr[$num] = $product;
var_dump($resarr);
echo "<hr />";
}
$id = array(8,31,32);
$resarr = array();
foreach($id as $num)
{
$product = array(
array(
'pid'=>'10',
'name'=>'产品1'
),
array(
'pid'=>'11',
'name'=>'产品2'
)
);
foreach($product as $key => $value)
{
$result_value = "";
foreach($value as $k => $v)
{
$result_value .= $result_value ? "
------解决方案--------------------
" : "";
$result_value .= $v['pid'];
}
$product[$key]['value'] = $result_value;
}
$resarr[$num] = $product;
}
var_dump($resarr);
echo "<hr />";