PHP array, condition, and loop statement learning. For more information, see
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: