Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. <?php
  2. $students = array(
  3. 'student1' => array(
  4. 'name' => "Ronny Berntsen",
  5. 'stud_id' => "123456",
  6. 'GPA' => "4.5"
  7. ),
  8. 'student2' => array(
  9. 'name' => "Sondre Berntsen",
  10. 'stud_id' => "123456",
  11. 'GPA' => "4.5"
  12. ),
  13. 'student3' => array(
  14. 'name' => "Ultin Berntsen",
  15. 'stud_id' => "123456",
  16. 'GPA' => "4.5"
  17. ),
  18. 'student4' => array(
  19. 'name' => "Herbert Berntsen",
  20. 'stud_id' => "123456",
  21. 'GPA' => "4.5"
  22. ),
  23. 'student5' => array(
  24. 'name' => "Vilde Berntsen",
  25. 'stud_id' => "123456",
  26. 'GPA' => "4.5"
  27. ),
  28. 'student6' => array(
  29. 'name' => "Nina Berntsen",
  30. 'stud_id' => "123456",
  31. 'GPA' => "4.5"
  32. ),
  33.  
  34. );
  35. /*
  36. foreach ($students as $student => $stud_info)
  37. foreach ($stud_info as $key => $value)
  38. echo "$student: $key = $value<br>";
  39. */
  40.  
  41.  
  42.  
  43. foreach ($students as $student) {
  44.  
  45. $studCount = 0;
  46. foreach ($students as $student) {
  47. $studCount++;
  48. echo "$studCount:<br>";
  49.  
  50. };
  51. foreach ($student as $subKey => $value) {
  52. echo "$subKey: $value<br>";
  53. };
  54. };
  55.  
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement