Q & A programming language.-php Tutorial

Source: Internet
Author: User
Answers to white programming. 1. declare a number of five members (each member contains the member id, name, age, gender, and registration time information), and then present the data in a table, if the age is less than 18 ~ 30 young people, 30 ~ 60 shows middle-aged, 60 or more shows elderly, and count the number of people of different age groups

2. use the for loop to create a 9-9 Multiplication table

3. use the while loop ~ Locate the prime number between 500 --> array

4. $ year indicates that the leap year outputs 366; otherwise, the output is 365.


Reply to discussion (solution)

Job?
1.

 1, 'name' => 'A', 'age' => 17, 'addtime' => date ('Y-m-D ')), array ('id' => 2, 'name' => 'B', 'age' => 19, 'addtime' => date ('Y-m-D'), array ('id' => 3, 'name' => 'C ', 'age' => 31, 'addtime' => date ('Y-m-D'), array ('id' => 4, 'name' => 'D', 'age' => 62, 'addtime' => date ('Y-m-D ')), array ('id' => 5, 'name' => 'e', 'age' => 18, 'addtime' => date ('Y-m-D'),); echo'
 '; Echo'
 
 
  
  
'; Echo'
  
  '; $ Agegroup = array (); foreach ($ arr as $ v) {$ agetype = checkage ($ v ['age']); if (isset ($ agegroup [$ agetype]) {$ agegroup [$ agetype] ++;} else {$ agegroup [$ agetype] = 1;} echo' 
   
     '; Echo' 
    '; Echo' 
    '; Echo' 
    '; Echo' 
    '; Echo' 
    '; Echo' 
   ';} Echo' 
  
Id Name Age Addtime Age Group
'. $ V ['id'].''. $ V ['name'].''. $ V ['age'].''. $ V ['addtime'].''. $ Agetype .'
'; Echo' statistical result
'; Foreach ($ agegroup as $ k => $ v) {echo $ k.': '. $ v .'
';} Function checkage ($ age) {if ($ age <18) {return 'minor';} elseif ($ age >=18 & $ age <30) {return 'youth ';} elseif ($ age >=30 & $ age <60) {return 'middle-aged';} else {return 'elder ';}}?>


2.
echo '
 
 
  
  ';for($i=1; $i<=9; $i++){    echo '
  
  
     '; for($j=1; $j<=9; $j++){ echo ' 
    '; } echo ' 
   ';}echo ' 
  
'.$i.'*'.$j.'='.($i*$j).'
';


3.
 


4.
echo checkyear('2016');function checkyear($year){    if($year%4==0 && $year%100!=0 || $year%400==0){        return 366;    }else{        return 365;    }}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.