Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. foreach ($record as $data) {
  2. $mArray = array();
  3. $name = $data['user'];
  4. $customer = $data['customer'];
  5. $project = $data['project'];
  6. $hours = $data['hours'];
  7.  
  8. $mArray[$name][$customer][$project] += $hours;
  9. }
  10.  
  11. foreach ($mArray as $username) {
  12. foreach ($mArray[$username] as $customerName) {
  13. foreach ($mArray[$username][$customerName] as $project ) {
  14. echo '<'.$username.'><'.$customerName.'><'.$project.'><hours>'.
  15. $mArray[$username][$customerName][$project].'</hours></'.$project.'>
  16. </'.$customerName.'></'.$username.'>';
  17. }
  18. }
  19. }
  20.  
  21. foreach ($mArray as $userKey => $username) {
  22. foreach ($mArray[$userKey] as $customerKey => $customerName) {
  23. foreach ($mArray[$userKey][$customerKey] as $projectKey => $projectName) {
  24. echo '<name>'.$userKey.'</name>';
  25. echo "n";
  26. echo '<customerName>'.$customerKey.'</customerName>';
  27. echo "n";
  28. echo '<projectName>'.$projectKey.'</projectName>';
  29. echo "n";
  30. echo '<hours>'.$mArray[$userKey][$customerKey][$projectKey].'</hours>';
  31. echo "n";
  32. }
  33. }
  34. }
  35.  
  36. foreach($mArray as $username) {
  37. foreach($username as ...)
  38.  
  39. foreach($mArray as $key => $user) {
  40. foreach($mArray[$key] as ...)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement