Format Display problems

Source: Internet
Author: User
Format Display problems
$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.'
';}}


Mainly added
The last line contains spaces. You can remove spaces in the last line. Thank you!


Reply to discussion (solution)

$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('
', $lotno_count);
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('
', $lotno_count);
4409*300
4410*75


What if this happens?
Foreach ($ ress as $ source)
{
If ($ source ['cust _ no'] = '237033aw0a ')
{
If ($ source ['part _ count']! = 0)
{
$ Lotno_count [] = $ source ['lotno']. '*'. $ source ['part _ count'];
}
}
}

What is the difference?
You only need to output the final output

No need to cache the last one.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.