Technical Test For Candidate
Technical Test For Candidate
There are a total of 26 questions in this Technical Test. Please complete the test by end of
the day and return it back to us. If you need to refer to the PHP or SQL documentation,
please feel free to do so.
Question 1
Write a PHP function which takes in an array of strings and returns an array of lengths of
all the strings in the given array.
Question 2
Write a PHP function which takes in a string and returns the length of the string if the
given string is a palindrome and returns false if the given string is not a palindrome.
For example, given the string “aabaa”, your function should return 5. Given the string
“daba”, your function should return false.
Question 3
Write a PHP function which takes in an array of integers and returns the sum of only the
even integers in the given array.
For example, given the array [15,18,3,9,6,2,12], your function should return 38.
Question 4
Write a SQL query which shows the following information for each member in the
members table.
Table: tbl_members
+-------------+---------+
+-------------+---------+
| member_id | int |
| first_name | varchar |
| last_name | varchar |
+-------------+---------+
Table: tbl_addresses
+-------------+---------+
+-------------+---------+
| address_id | int |
| member_id | int |
| city | varchar |
| state | varchar |
+-------------+---------+
address_id is the primary key column for this table and member_id is the foreign
key which references member_id in tbl_members table.
Question 5
We have 2 tables, tbl_clients table and tbl_invoices table. Write a SQL query to find all the
clients who have no invoices.
Table: tbl_clients.
+----+-------+
| Id | Name |
+----+-------+
| 1 | Susan |
| 2 | Jake |
| 3 | Tom |
| 4 | Peter |
+----+-------+
Table: tbl_invoices.
+----+------------+
| Id | cient_id |
+----+------------+
| 1 | 3 |
| 2 | 1 |
+----+------------+
For example, the following should be returned for the above data.
+-----------+
| Clients |
+-----------+
| Jake |
| Peter |
+-----------+
Question 6
Our contacts table shown below contains repeated mobile numbers. Write a SQL query to find all the
phone numbers which appear more than once in the table.
+----+---------+
| Id | Mobile |
+----+---------+
| 1 | 92387974 |
| 2 | 92111930 |
| 3 | 92387974 |
+----+---------+
For example, your query should return the following for the above data set:
+---------+
| Mobile |
+---------+
| 92387974 |
+---------+
Question 7
For example, given the csrf_set_hash(), your function should return the random has csrf
key.
Question 8
Write a PHP class that sorts an ordered integer array with the help of sort() function.
Sample array:array(13, -2, 4, 30, 1, 8, -5)
Sample Output:
Array
(
[0] => -5
[1] => -2
[2] =>1
[3] => 4
[4] => 8
[5] => 13
[6] => 30
Question 9
Write a PHP program to create a new string which is 4 copies of the 2 front characters of a
given string. If the given string length is less than 2 return the original string.
Sample Output:
CCCC
JSJSJSJS
A
Question 10
Question 11
Question 12
Write a query to get the average salary for all departments employing more than 10
employees.
Sample Output:
Question 13
Accepts an associative array containing the file owner name for each file name.
Returns an associative array containing an array of file names for each owner name,
in any order.
For example, for associative array ["Input.txt" => "Randy", "Code.py" => "Stan", "Output.txt"
=> "Randy"] the groupByOwners function should return ["Randy" => ["Input.txt",
"Output.txt"], "Stan" => ["Code.py"]].
Question 14
Question 15
Question 17
Question 18
Question 19
Question 20
Question 21
Question 22
Question 23
Question 24
Question 25
Question 26