PHP array and condition, and loop statement learning _ PHP Tutorial

Source: Internet
Author: User
PHP array, condition, and loop statement learning. 1. array instance). Preview: 2). Code: The following is a two-dimensional array, the actual use of more. $ messarray (title message title 1, content, ctime2012-1 1. array

Instance 1:

1). preview:

2). Code:

The following is a two-dimensional array, which is usually used.

$ Mess = array ('title' => 'message title 1', 'content' => 'content', 'ctime' => '2017-1-1 12:34:23 '); // associate an array

// Statement used to traverse the array

// First
Foreach ($ mess as $ v) {// foreach can traverse the associated array; while for loop can only traverse the enumerated array, not the associated array.
// $ V is the value of an array element. the number of cycles is determined by the array element.
Echo $ v .'
';
}

// Type 2
Foreach ($ mess as $ k =>v v ){
// $ K is used to receive the key name or index corresponding to the data element. $ v is the value of the received array element.
Echo $ k. '-----'. $ v .'
';

Instance 2:

1). preview:

2). Code:

Http://www.bkjia.com/PHPjc/326316.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/326316.htmlTechArticle1. array instance 1: 1 ). preview: 2 ). code: The following is a two-dimensional array, which is usually used. $ mess = array ('title' = 'message title 1', 'content' = 'content', 'ctime' = '2017-1...

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.