Today I would like to share interview question for PHP Developer. Litebreeze (Kochi) conduct online test for PHP developer. The online test aims at testing the quality of your code. You will develop one function. Their focus is on the neatness of the solution; logic used, code efficiency and formatting. Minimize the number of lines; you don't have to declare variable, add comments or write any HTML (except maybe a pre tag to format array output).
There will be only one question and the time limit will be 45 Minutes. If you complete earlier we recommend that you take some extra time to perfect the code, such as formatting and minimizing the number of lines of code used.
The functions you develop should display the exact return values given in the test instructions.
Question is like this, you need to write a function that will fetch 5 random number (between 0 & 9) and create a associate array such that key will the the random value that generated and value as 2 * preciding key (for 1st key value will be 2 * key of last key). For example array(=>6, =>2, =>10, =>8, =>18).
Then you need to print the array using print_r, later sort array in ascending order and then print again.
Your answer will be some what like this,
This answer may or mayn't be correct. Please share your answer.