[英]Split mysql_fetch_array result into two different two different rows in front end
我的SQL查询中有一组数组
Array
(
[0] => stdClass Object
(
[id] => 1
[DSR] => 1016130
[aplan] => $90-Standard
[plan] => $44-Standard
[cli] => 089561287
[mobile] => 0428333999
)
现在,它显示在单行中,但是我试图通过键[aplan]和[plan]将其分为两行。
电流输出
1|1016130|$90-Standard|$44-Standard|089561287|0428333999
渴望将
1|1016130|$90-Standard|089561287|0428333999
2|1016130|$44-Standard|089561287|0428333999
将感谢您的帮助。
假设您的0索引是$arr
。 请注意,您具有相同的ID,因此输出的第一个值应为1。如果您想要为1,则为2.。然后需要一些配料。
$plan = array();
$aplan = array();
foreach($arr as $key => $value){
if($key == 'aplan' || $key == 'plan'){
if($key == 'aplan')
$aplan[] = $value;
else
$plan[] = $value;
}
else{
$plan[] = $value;
$aplan[] = $value;
}
}
echo implode("|", $aplan); // 1|1016130|$90-Standard|089561287|0428333999
echo implode("|", $plan); // 1|1016130|$44-Standard|089561287|0428333999
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.