Guest User

Untitled

a guest
Nov 14th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. array(5) {
  2. [01081] => Array(3){
  3. [id] => 2
  4. [Mark] => 420
  5. [lastUpdated] => 2010-03-17 15:44:12
  6. [dataNext] => Array(2){
  7. [more1] => 54
  8. [More2] => 54
  9. }
  10. }
  11. [00358] => Array(3){
  12. [id] => 6
  13. [Mark] => 500
  14. [lastUpdated] => 2010-03-17 15:44:12
  15. [dataNext] => Array(2){
  16. [more1] => 54
  17. [More2] => 54
  18. }
  19. }
  20. [00277] => Array(3){
  21. [id] => 3
  22. [Mark] => 400
  23. [lastUpdated] => 2010-03-17 15:44:12
  24. [dataNext] => Array(2){
  25. [more1] => 54
  26. [More2] => 54
  27. }
  28. }
  29. [00357] => Array(3){
  30. [id] => 1
  31. [Mark] => 500
  32. [lastUpdated] => 2010-03-17 15:44:12
  33. [dataNext] => Array(2){
  34. [more1] => 54
  35. [More2] => 54
  36. }
  37. }
  38. }
  39.  
  40. array(3) {
  41. [0400] => Array(1){
  42. [count] => 1
  43. [element] => '00277'
  44. }
  45. [0420] => Array(1){
  46. [count] => 1
  47. [element] => '01081'
  48. }
  49. [0500] => Array(1){
  50. [count] => 2
  51. [element] =>'00357,00358'
  52. }
  53. }
  54.  
  55. $arr = [
  56. '01081' => [
  57. 'id' => 2,
  58. 'Mark' => 420,
  59. 'lastUpdated' => '2010-03-17 15:44:12',
  60. 'dataNext' => [
  61. 'more1' => 54,
  62. 'More2' => 54,
  63. ]
  64. ],
  65. '00358' => [
  66. 'id' => 6,
  67. 'Mark' => 500,
  68. 'lastUpdated' => '2010-03-17 15:44:12',
  69. 'dataNext' => [
  70. 'more1' => 54,
  71. 'More2' => 54,
  72. ]
  73. ],
  74. '00277' => [
  75. 'id' => 3,
  76. 'Mark' => 400,
  77. 'lastUpdated' => '2010-03-17 15:44:12',
  78. 'dataNext' => [
  79. 'more1' => 54,
  80. 'More2' => 54,
  81. ]
  82. ],
  83. '00357' => [
  84. 'id' => 1,
  85. 'Mark' => 500,
  86. 'lastUpdated' => '2010-03-17 15:44:12',
  87. 'dataNext' => [
  88. 'more1' => 54,
  89. 'More2' => 54,
  90. ]
  91. ]
  92. ];
  93.  
  94. $result = [];
  95.  
  96. foreach($arr as $id => $data) {
  97.  
  98. if (! isset($result[$data['Mark']])) {
  99. $result[$data['Mark']] = [
  100. 'count' => 1,
  101. 'element' => $id
  102. ];
  103. } else {
  104. $result[$data['Mark']]['count']++;
  105. $result[$data['Mark']]['element'] = $result[$data['Mark']]['element'] .','.$id;
  106. }
  107.  
  108. }
  109. ksort($result);
  110. print_r($result);
Add Comment
Please, Sign In to add comment