Use foreach instead of while to traverse the array. When traversing an array, foreach is much more efficient than while loop, and you do not need to call the reset function. The two traversal methods are as follows:
1. replace I = I 1 with I = 1. In line with c/c habits, high efficiency.
2. apply PHP internal functions as much as possible. Before writing a function, check the manual to see if there are any related functions.
3. use single quotes as much as possible. The efficiency of a single quotation mark string is higher than that of a double quotation mark string.
4. use foreach instead of while to traverse the array. When traversing an array, foreach is much more efficient than while loop, and you do not need to call the reset function. The two traversal methods are as follows:
Reset ($ arr );
While (list ($ key, $ value) = each ($ arr )){
Echo 'key: $ Key; Value: $ value
N ';
}
Foreach ($ arr as $ key => $ value ){
Echo 'key: $ Key; Value: $ value
N ';
}