首页 >后端开发 >php教程 >格式显示有关问题

格式显示有关问题

WBOY
WBOY原创
2016-06-13 11:55:161233浏览

格式显示问题

$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, ), )<br /><br />foreach($ress as $source)<br />			{	<br />					if($source['part_count'] != 0)<br />					{<br />						$lotno_count = $source['lotno'].' * '.$source['part_count'];<br />						echo $lotno_count.'<br />';<br />					}<br />			}


主要是加了
最后一行显示空格。如何修改可以把最后一行多的空格去除。谢谢!
------解决方案--------------------
$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, ), );<br /> <br />foreach($ress as $source) {   <br />  if($source['part_count'] != 0)<br />  {<br />    $lotno_count[] = $source['lotno'].' * '.$source['part_count'];<br />  }<br />}<br />echo join('<br />', $lotno_count);<br />
4409 * 300
4410 * 75

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

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

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn