Job Recruitment Website - Job information - How to change the color of every 5 pieces of data with PHP
How to change the color of every 5 pieces of data with PHP
ul? Li? List style:? None; ? Width:? 20%; ? Floating:? Left; }
. Red? Color:? # ff0000}
. Blue {? Color:? # 0000ff}
& lt/style & gt;
& ltdiv & gt
& ltul & gt
& lt? Server-side programming language (abbreviation of professional hypertext preprocessor)
$array? =? Array ('1',? ' 1',? ' 1',? ' 1',? ' 1',? '2',? '2',? '2',? '2',? '2',? '3');
foreach($array? As? $ key = & gt$val){
$style? =? $key/5%2? ==? 0? class="red " '? :? class = " blue " ';
& gt
& lt Li? & lt? php? echo($ style); & gt& gt& lt? php? echo($ val); & gt& lt/ Li>
& lt? Server-side programming language (abbreviation of professional hypertext preprocessor)
}
& gt
& lt/ul & gt;
& lt/div & gt; This effect can be judged by the value of $key.
First, divide the quotient obtained by 5 by the value of $key, which can be understood as the number of rows, that is, the elements displayed in the first row with the quotient of $key/5 of 0, and so on.
Because every two lines will change color, so
Then use the obtained quotient to find the remainder divided by 2,
Assign styles to single and double lines
You can specify another style after the line is finished.
- Related articles
- Summary of Public Middle Schools in Chenzhou City
- Which community in Xiangyang is public?
- How to write a resume? How to optimize your resume?
- How to get to wanda plaza from Meishan People's Hospital?
- Do some netizens in Beijing know if there is China Beijing Culture Publishing Co., Ltd. on the 3rd floor of China News Agency at Baiwanzhuang South Street 12?
- Can Dongdong Film and Television Media do event planning?
- What about Wuxi Jinzhen Automation Technology Co., Ltd.?
- The central government's view on the joint development of housing bank
- How many Kaiyuan temples are there in China?
- What are the applications of business data analysis?