fork(1) download
  1. <?php
  2.  
  3.  
  4. class Worker
  5. {
  6. public function __construct($salary, $coffee, $reports)
  7. {
  8. $this->salary = $salary;
  9. $this->coffee = $coffee;
  10. $this->reports = $reports;
  11. }
  12. }
  13. $me = array(
  14. 500,
  15. 20,
  16. 200
  17. );
  18. $ma = array(
  19. 400,
  20. 15,
  21. 150
  22. );
  23. $en = array(
  24. 200,
  25. 5,
  26. 50
  27. );
  28. $an = array(
  29. 800,
  30. 50,
  31. 5
  32. );
  33. function doShit($array)
  34. {
  35. $workers = array();
  36. foreach ($array as $k => $v) {
  37. if ($k == 0) {
  38. $k1 = $v;
  39. } elseif ($k == 1) {
  40. $k2 = $v;
  41. } elseif ($k == 2) {
  42. $k3 = $v;
  43. }
  44.  
  45. }
  46. $worker = new Worker($k1, $k2, $k3);
  47. $workers[] = $worker;
  48. return $workers;
  49. }
  50. doShit($me);
  51. var_dump($workers);
Success #stdin #stdout #stderr 0.01s 20520KB
stdin
Standard input is empty
stdout
NULL
stderr
PHP Notice:  Undefined variable: workers in /home/2DOpOv/prog.php on line 52