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