Home > Backend Development > PHP Tutorial > Classic example of Windows XP hardware optimization PHP code optimization

Classic example of Windows XP hardware optimization PHP code optimization

WBOY
Release: 2016-07-29 08:44:37
Original
1243 people have browsed it

The method I used was to distinguish blocks by key, then assign the blocks to other variables, and then perform some operations. This used a lot of for and foreach, and the amount of code was also large, so it was returned.
After the above guidance, I found that it is really simple, and now I will share it with you.

ID
FIELD1
FIELD2 FIELD3 FIELD4 Key
1
*** *** *** *** meat1
2
*** *** *** *** meat1
3
*** *** *** *** meat1
4 *** ** * *** *** meat1
5
*** *** *** *** fruit2
6 *** *** *** *** fruit2
7
*** *** *** *** fruit2
8
*** *** *** *** fruit2
9
*** *** *** *** fruit2
10
*** *** *** *** food3
11
*** *** *** *** food3

Now there is the result shown above

Requirement: To operate on this array that has been sorted by key, items with the same key for processing.

Tips: This is a very typical structure of a parent-child table, which means it is actually a merger of two tables. It can be processed into two arrays to facilitate block operations in the array
array1:ID|Key

ID
Key
1
meat1
2
meat1
3
meat1
4 meat1
5
fruit2
6 fruit2
7
fruit2
8
fruit2
9
fruit2
10
food3
11
food3

array2:key => array(ID,FIELD1,FIELD2,FIELD3,FIELD4,FIELD5,Key)

3************ meat14fruit2=>*** *********fruit26************fruit28******* *****fruit29************fruit2food3=>10***************food3************food3After this, it is very convenient to access the block data of tempArrayforeach($tempArray as $row){ array1[$row[' ID']] = $row['Key']; array2[$row['Key']][] = $row;}Access and processing codeforeach($array1 as $ID = > Key]

ID
FIELD1
FIELD2 FIELD3 FIELD4 Key
meat1=>
2
*** *** *** *** meat1


***
*** *** *** meat1
5

***
*** *** *** fruit2
7




11
Implement the above array separation code
);

}

The above introduces the classic examples of Windows XP hardware optimization and PHP code optimization, including the content of Windows XP hardware optimization. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template