A solution to the circular judgment

Source: Internet
Author: User
On the circular judgment
Like I read 10 messages from the data table.
Where the 5th output mode is
  • ". $row 1[' title ']."

  • 6th output Mode
      • ". $row 1[' title ']."

      • 10th output Mode
      • ". $row 1[' title ']."

    Every other one is
  • ". $row 1[' title ']."

  • How do you write it?
    Here's your own mess.
    for ($i =0; $i <= $num; $i + +) {
    if (? ):
    echo "
  • ". $row 1[' title ']."
  • ";
    ElseIf (? ):
    echo "
      • ". $row 1[' title ']."
      • ";
        ElseIf (? )://Note the ELS using a word
        echo "
      • ". $row 1[' title ']."
    ";
    Else
    echo "
  • ". $row 1[' title ']."
  • ";
    endif
    }
    Or read 10 of messages
    is a group of 5
    Output is

      • 1

      • 2

      • 3

      • 4

      • 5



      • 6

      • 7

      • 8

      • 9

      • 10


    How do you write it?
    ------to solve the idea----------------------
    Basic algorithms
    $a = array (1,2,3,4,5,6,7,8,9,10);
    for ($i =0; $i <10; $i + +) {
    if ($i% 5 = = 0)
    Echo ($i? '' : '') . "
      \ n";
      echo "
    • $i
    • \ n ";
      }
      Echo '
    ;
     
      

    • 0

    • 1

    • 2

    • 3

    • 4


    • 5

    • 6

    • 7

    • 8

    • 9



    ------to solve the idea----------------------

    $row = Array (0,1,2,3,4,5,6,7,8,9,10,11);

    foreach (Array_chunk ($row, 5) as $val) {
    echo "
      ". " \ n ";
      foreach ($val as $v) {
      echo "
    • " . $v. "
    • "." \ n ";
      }
      echo "
    ". " \ n ";
    }




    • 0

    • 1

    • 2

    • 3

    • 4



    • 5

    • 6

    • 7

    • 8

    • 9



    • 10

    • 11


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