格式显示问题

WBOY
Release: 2016-06-23 13:58:37
Original
773 people have browsed it

$ress = array ( 0 => array ( 0 => '237033AW0A', 'cust_no' => '237033AW0A', 1 => '4409', 'lotno' => '4409', 2 => 300, 'part_count' => 300, ), 1 => array ( 0 => '237033AW0A', 'cust_no' => '237033AW0A', 1 => '4410', 'lotno' => '4410', 2 => 141, 'part_count' => 75, ), )foreach($ress as $source)			{						if($source['part_count'] != 0)					{						$lotno_count = $source['lotno'].' * '.$source['part_count'];						echo $lotno_count.'<br />';					}			}
Copy after login


主要是加了
最后一行显示空格。如何修改可以把最后一行多的空格去除。谢谢!


回复讨论(解决方案)

$ress = array ( 0 => array ( 0 => '237033AW0A', 'cust_no' => '237033AW0A', 1 => '4409', 'lotno' => '4409', 2 => 300, 'part_count' => 300, ), 1 => array ( 0 => '237033AW0A', 'cust_no' => '237033AW0A', 1 => '4410', 'lotno' => '4410', 2 => 141, 'part_count' => 75, ), ); foreach($ress as $source) {     if($source['part_count'] != 0)  {    $lotno_count[] = $source['lotno'].' * '.$source['part_count'];  }}echo join('<br />', $lotno_count);
Copy after login
Copy after login
4409 * 300
4410 * 75

$ress = array ( 0 => array ( 0 => '237033AW0A', 'cust_no' => '237033AW0A', 1 => '4409', 'lotno' => '4409', 2 => 300, 'part_count' => 300, ), 1 => array ( 0 => '237033AW0A', 'cust_no' => '237033AW0A', 1 => '4410', 'lotno' => '4410', 2 => 141, 'part_count' => 75, ), ); foreach($ress as $source) {     if($source['part_count'] != 0)  {    $lotno_count[] = $source['lotno'].' * '.$source['part_count'];  }}echo join('<br />', $lotno_count);
Copy after login
Copy after login
4409 * 300
4410 * 75


如果变成这样呢?
foreach($ress as $source)
{
if($source['cust_no'] == '237033AW0A')
{
if($source['part_count'] != 0)
{
$lotno_count[] = $source['lotno'].' * '.$source['part_count'];
}
}
}

那有什么区别呢?
你不过只是在直接输出时多了最后的 

只要能判断出是最后一个就不需要缓存了

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template