You are on page 1of 2

PHP Questions for Test

Question: 1
Write code for given program.

$array_points = [98,98,98,100,99,97, 95, 93, 93, 95, 90, 90, 98];


$prize_to_give = [10000, 5000, 4000, 3000, 2500, 2000, 1800, 1500, 1200, 1100, 1000,
900, 750];

Where variable array_points denotes earned points and variable prize_to_give denotes
price as per rank.

You have to find out through $array_points(Max points will be rank 1), if points are
equal then add both rank amount and distribute equally.

Example: Points – 100. (Rank will be 1 and prize amount will be 10,000)
Points – 99. (Rank will be 2 and prize amount will be 5000)
Points – 98 (Rank will be 3 for four persons and prize amount will be
4000+3000+2500+2000= 11500/4 = 2875 for all four as rank 3)
Next Rank will be 7 with 97 Points and prize will be 1800 and so on…

Question: 2
Write code for sorting an array without using php function.

$array=array('2','4','8','5','1','7','6','9','10','3');

Question 3
Write a program in PHP to print Fibonacci series . 0, 1, 1, 2, 3, 5, 8, 13, 21, 34

Question 4

Write a Program for finding the smallest number in an array


$numbers=array(12,23,45,20,5,6,34,17,9,56);

Question 5

Write a program to print the below format :


1 5 9
2 6 10
3 7 11
4 8 12

1. Make function to add two numbers


2. Create a table in 3 NF User, User result
3. Sign Up form / Email Script/ Email verification Process
4. Image upload
5. Sql Injection Prevention
6. Delete a file from folder
7. Create cookie for user login
Write logic to print Floyd's triangle in PHP?
1

23

456

7 8 9 10
8. How to add 301 redirects in PHP?
header("HTTP/1.1 301 Moved Permanently");
header("Location: /option-a");
exit();

9. 14. How to get the IP address of the client/user in PHP?


10. Code to post JSON Data in a URL using CURL in PHP

You might also like