fork download
  1. <?php
  2.  
  3. /* This is a test assignment
  4. Assignment: Filter Employees by Salary Range and Sort by Hire Date
  5. Objective:
  6. You are given a JSON string containing employee data with name, salary, and hire_date.
  7. Write a PHP function that:
  8. -> Filters employees with salaries in a specified range (e.g., $40,000 to $90,000).
  9. -> Sorts them by hire date in ascending order.
  10. -> Returns a comma-separated list of employee names with hire dates.
  11.   eg. David Jones (2017, October 22)
  12.   Emily White (2018, April 12)
  13. */
  14. $json_data = '{
  15. "18719": {"name": "John Doe", "salary": 75000, "hire_date": "2019, May 01"},
  16. "18720": {"name": "Jane Smith", "salary": 45000, "hire_date": "2021, January 15"},
  17. "18721": {"name": "David Jones", "salary": 60000, "hire_date": "2017, October 22"},
  18. "18722": {"name": "Susan Green", "salary": 95000, "hire_date": "2015, August 05"},
  19. "18723": {"name": "Michael Lee", "salary": 30000, "hire_date": "2020, November 10"},
  20. "18724": {"name": "Emily White", "salary": 80000, "hire_date": "2018, April 12"},
  21. "18725": {"name": "Robert Brown", "salary": 68000, "hire_date": "2016, December 14"},
  22. "18726": {"name": "Sophia Harris", "salary": 72000, "hire_date": "2022, March 18"},
  23. "18727": {"name": "William Clark", "salary": 54000, "hire_date": "2021, July 07"},
  24. "18728": {"name": "Olivia Lewis", "salary": 46000, "hire_date": "2019, August 19"},
  25. "18729": {"name": "Liam Walker", "salary": 62000, "hire_date": "2018, February 25"},
  26. "18730": {"name": "Mia Martinez", "salary": 53000, "hire_date": "2020, September 30"},
  27. "18731": {"name": "Noah Wilson", "salary": 70000, "hire_date": "2017, June 11"},
  28. "18732": {"name": "Emma Robinson", "salary": 48000, "hire_date": "2016, April 05"},
  29. "18733": {"name": "Lucas Scott", "salary": 59000, "hire_date": "2019, November 20"}
  30. }';
Success #stdin #stdout 0.02s 25640KB
stdin
Standard input is empty
stdout
Standard output is empty