How to simplify the code below

Source: Internet
Author: User
if ($_module[huoqubaobei]!= "4") {$i =-1; $j =0;    foreach ($items as $item) {$i + +;        $ITEMURL = $uriManager->detailuri ($item);         $ITEMPICURL = $item->getpicurl (310);        $itemTitle = $item->title;        $itemPrice = $item->price;        $itemsoldCount = $item->soldcount; Echo '. $itemTitle. ' ¥ '. $itemPrice. ';}} else if ($_module[huoqubaobei]== "4") {$num = count ($SRTPDZ);    for ($i =0; $i < $num; $i + +)    {echo '. $SRBBBT [$i]. ' ¥ '. $SRBBJG [$i]. ';}}


This place div+css write repeats I want not to repeat how to write. I thought for a couple of hours I couldn't figure out a good way to do this. The main loop is the egg ache.


Reply to discussion (solution)

I don't think we can squeeze much more.

Because the mixed code is too complicated, so the template engine appears



'. $SRBBBT [$i]. '

'. $SRBBJG [$i]. '



';

I don't think that's a repeat, huh?

No one knows????????????????????????????????????

I really want to put the echo out of the code with another function to output.

How to simplify and save a lot of code, that's it.

  • 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.