Sr. No. | Category | Question |
1. |
Basic Syntax and Variables |
Write a PHP script to display the current date and time. |
2. |
Basic Syntax and Variables |
Create a PHP script to swap the values of two variables without using a third variable. |
3. |
Control Structures |
Write a PHP program to check if a given number is a prime number. |
4. |
Control Structures |
Write a PHP script to generate the first 10 Fibonacci numbers. |
5. |
Functions in PHP |
Create a PHP function to reverse a string. |
6. |
Functions in PHP |
Write a PHP function to calculate the factorial of a number. |
7. |
Arrays in PHP |
Write a PHP script to find the largest and smallest elements in an array. |
8. |
Arrays in PHP |
Create a PHP function to merge two arrays and remove duplicate values. |
9. |
Strings in PHP |
Write a PHP script to count the number of vowels in a given string. |
10. |
Strings in PHP |
Create a PHP function to check if a string is a palindrome. |
11. |
File Handling |
Write a PHP script to read the contents of a file and display it. |
12. |
File Handling |
Create a PHP script to write a string to a file. |
13. |
Database Interaction |
Write a PHP script to connect to a MySQL database and retrieve data from a table. |
14. |
Database Interaction |
Create a PHP script to insert a new record into a MySQL database table. |
15. |
Object-Oriented Programming |
Write a PHP class to represent a "Book" with properties for title, author, and price, and methods to get and set these properties. |
16. |
Object-Oriented Programming |
Create a PHP script that uses inheritance to extend the "Book" class to a "EBook" class with an additional property for file format. |
17. |
Array-Based Questions |
Write a function to find the second largest element in an array. |
18. |
Array-Based Questions |
Given an array of integers, return pairs of numbers that add up to a given sum. |
19. |
Array-Based Questions |
Write a function to remove duplicate elements from an array without using built-in functions. |
20. |
Array-Based Questions |
Rotate an array by n positions to the right. |
21. |
Array-Based Questions |
Find a subarray with a given sum in an array of positive integers. |
22. |
Array-Based Operations |
Create an array with 10 numbers. Write a script to find the sum and average of the array elements. |
23. |
Array-Based Operations |
Sort an array of strings in alphabetical order and display the result. |
24. |
Array-Based Operations |
Write a function to remove duplicate elements from an array without using built-in functions. |
25. |
Array-Based Manipulation |
Write a function to remove duplicate values from an array. |
26. |
Array-Based Manipulation |
Reverse an array without using built-in functions and display the reversed array. |
27. |
Array-Based Manipulation |
Merge two arrays into a single array and remove any duplicate values. |
28. |
Array-Based Searching and Filtering |
Write a function to check if a specific value exists in an array. |
29. |
Array-Based Searching and Filtering |
Filter an array to return only even numbers. |
30. |
Array-Based Searching and Filtering |
Find the index of a specific value in an array. |
31. |
Array-Based Multi-Dimensional Arrays |
Create a 2D array representing a matrix and write a script to display its transpose. |
32. |
Array-Based Multi-Dimensional Arrays |
Write a function to sum all elements in a multi-dimensional array. |
33. |
Associative Array-Based Basic Operations |
Create an associative array representing a person with keys for name, age, and email. Write a script to display each value. |
34. |
Associative Array-Based Basic Operations |
Add a new key-value pair to an existing associative array and display the updated array. |
35. |
Associative Array-Based Manipulation |
Write a function to update the value of a specific key in an associative array. |
36. |
Associative Array-Based Manipulation |
Remove a key-value pair from an associative array and display the updated array. |
37. |
Associative Array-Based Searching and Filtering |
Write a function to check if a specific key exists in an associative array. |
38. |
Associative Array-Based Searching and Filtering |
Filter an associative array to return only elements where the value meets a certain condition. |
39. |
Nested Associative Arrays |
Create a nested associative array representing a company's employees with departments and roles. Write a script to display all employee names in a specific department. |
40. |
Nested Associative Arrays |
Write a function to add a new employee to a specific department in the nested associative array. |
41. |
Combining Arrays |
Combine two associative arrays into one, with the second array's values overwriting the first array's values where keys overlap. |
42. |
Data-Oriented Questions |
Write a function to flatten a multidimensional array. |
43. |
Data-Oriented Questions |
Write a function to count the frequency of each element in an array. |
44. |
Data-Oriented Questions |
Write a function to merge two sorted arrays into one sorted array. |
45. |
Data-Oriented Questions |
Write a function to find common elements between two arrays. |
46. |
Data-Oriented Questions |
Given an array of strings, group anagrams together. |
47. |
Advanced Questions |
Implement a Least Recently Used (LRU) cache using arrays or linked lists. |
48. |
Advanced Questions |
Find the length of the longest consecutive elements sequence in an unsorted array. |
49. |
Advanced Questions |
Implement the Kadane’s Algorithm to find the maximum sum subarray. |
50. |
Advanced Questions |
Write a function that returns an array output such that output[i] is equal to the product of all the elements of arr except arr[i]. |
51. |
Advanced Questions |
Find the k most frequent elements in an array. |