Advertisement
shirker

php test for the applicants

Dec 5th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.67 KB | None | 0 0
  1. <?php
  2.  
  3. // 1
  4. // php arrays knowledge
  5. // Here are $products array. The owner wants to increase all the prices by 15%
  6. // please loop through the array and increase each price by 15%
  7. //
  8. // you may use http://phptester.net/ and print_r or var_dump to show the results
  9.  
  10. $products = [
  11.     'mop' => [
  12.         'quantity' => 18,
  13.         'price' => 12,
  14.     ],
  15.     'hammer' => [
  16.         'small' => [ 'quantity' => 2, 'price' => 24 ]
  17.     ],
  18.     'furniture' => [
  19.         'kitchen_stuff' => [
  20.             'chair' => [ 'quantity' => 7, 'price' => 53 ],
  21.             'table' => [
  22.                 'small' => [ 'quantity' => 8, 'price' => 113 ],
  23.                 'large' => [ 'quantity' => 1, 'price' => 214 ]
  24.             ]
  25.         ],
  26.         'sofa' => [ 'quantity' => 1, 'price' => 345 ]
  27.     ]
  28. ];
  29.  
  30.  
  31. // 2
  32. // MYSQL knowledge
  33. // here are 3 mysql tables
  34. // 1. Please make a mysql query to list users, but only those who have a car
  35. // <name> => <car name>
  36. //
  37. // 2. Please make a mysql query to pull out emails of only those users who have bmw model
  38.  
  39.  
  40. //users
  41. id | name | email
  42. -------------------
  43. 1  |  John | aaa@bbb.cc
  44. 2  |  Sara | abb@bbb.cc
  45. 3  |  David| abc@bbb.cc
  46. 4  |  Nick | acc@bbb.cc
  47. 5  |  Mike | aac@bbb.cc
  48.  
  49. //users_cars
  50. id | user_id | car_model_id
  51. ----------------------------
  52. 1  | 2       | 1
  53. 2  | 3       | 2
  54. 3  | 4       | 3
  55. 4  | 5       | 3
  56.  
  57. //car_models
  58. id | model
  59. ----------
  60. 1  | toyota
  61. 2  | kia
  62. 3  | bmw
  63.  
  64.  
  65.  
  66. // 3
  67. // HTML knowledge
  68. // Using codepen please create a html layout of a page
  69. // 80px - (bg yellow) header
  70. // 200px - (bg gray) bottom pushed to the bottom of the page. Pushed but not a fixed position.  
  71. // 20% of width - (bg red) side bar
  72. // 80% of width white main content
  73. // no scroll bar if main content is smaller than 100% of height.
  74. // footer should remind at the bottom but not overlay the content from main
  75. |------------------|<-header
  76. |__________________|
  77. |    |             |
  78. |    |             |
  79. |    |             |<--main block
  80. |    |             |
  81. |------------------|
  82. |   footer         |
  83. |------------------|
  84.  
  85. // 4 (optional)
  86. // JAVASCRIPT knowledge:
  87. var myNumber = 12;
  88.  
  89. // please make chinable function "doubleNumber"  (a prototype function) to have these results
  90.  
  91. console.log(myNumber.doubleNumber()); //24
  92. myNumber = 20;
  93. console.log(myNumber.doubleNumber()); //40
  94.  
  95. // 5
  96. // regex knowledge
  97. // here is part of a log file. Please retrieve by using regex
  98. // all emails that have sent us emails ( from=)
  99. // Please test the result at https://regex101.com/
  100. //
  101. received from="aaa@bbb.cc.uk" via="aaabbb.ee" ip="unknown" to="qqq@ccc.uu"
  102. received from="aab@bgb.cc" ip="11.22.33.44" to="qqq@ccc.uu"
  103. received from="acaf@hhh.cc" ip="unknown" to="qqq@ccc.uu"
  104. received from="ac56af@abc22.name" ip="88.55.21.56" to="qqq@ccc.uu"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement