pimplesushant-pere

merge

Apr 10th, 2019
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. public function getRawForTopFive()
  2. {
  3. $ad = array
  4. (
  5. "0" => array
  6. (
  7. "country_id" => 1,
  8. "speciality_id" => 1,
  9. "active_doctors" => 11
  10. ),
  11.  
  12. "1" => array
  13. (
  14. "country_id" => 1,
  15. "speciality_id" => 2,
  16. "active_doctors" => 6
  17. ),
  18.  
  19. "2" => array
  20. (
  21. "country_id" => 1,
  22. "speciality_id" => 4,
  23. "active_doctors" => 1
  24. ),
  25.  
  26. "3" => array
  27. (
  28. "country_id" => 1,
  29. "speciality_id" => 10,
  30. "active_doctors" => 1
  31. ),
  32.  
  33. "4" => array
  34. (
  35. "country_id" => 2,
  36. "speciality_id" => 1,
  37. "active_doctors" => 6
  38. ),
  39.  
  40. "5" => array
  41. (
  42. "country_id" => 2,
  43. "speciality_id" => 2,
  44. "active_doctors" => 1
  45. ),
  46.  
  47. "6" => array
  48. (
  49. "country_id" => 2,
  50. "speciality_id" => 3,
  51. "active_doctors" => 1
  52. ),
  53.  
  54. "7" => array
  55. (
  56. "country_id" => 2,
  57. "speciality_id" => 4,
  58. "active_doctors" => 2
  59. )
  60.  
  61. );
  62.  
  63. $pad = array
  64. (
  65. "0" => array
  66. (
  67. "country_id" => 1,
  68. "speciality_id" => 1,
  69. "pending_activation_doctors" => 7
  70. ),
  71.  
  72. "1" => array
  73. (
  74. "country_id" => 1,
  75. "speciality_id" => 2,
  76. "pending_activation_doctors" => 1
  77. ),
  78. "2" => array
  79. (
  80. "country_id" => 1,
  81. "speciality_id" => 8,
  82. "pending_activation_doctors" => 1
  83. ),
  84.  
  85. "3" => array
  86. (
  87. "country_id" => 1,
  88. "speciality_id" => 10,
  89. "pending_activation_doctors" => 1
  90. ),
  91.  
  92. "4" => array
  93. (
  94. "country_id" => 2,
  95. "speciality_id" => 1,
  96. "pending_activation_doctors" => 1
  97. ),
  98.  
  99. "5" => array
  100. (
  101. "country_id" => 2,
  102. "speciality_id" => 4,
  103. "pending_activation_doctors" => 2
  104. )
  105.  
  106. );
  107.  
  108. $is_diff = (count($ad) - count($pad));
  109.  
  110. $diff = ($is_diff < 0) ? ($is_diff * -1) : $is_diff;
  111.  
  112. for($i = 0; $i < $diff;$i++ ){
  113. if($is_diff < 0){
  114. array_push( $ad, array());
  115. }
  116. elseif($is_diff > 0){
  117. array_push($pad,array());
  118. }
  119. }
  120.  
  121.  
  122. $out = array();
  123. foreach ($ad as $key => $value){
  124. $out[] = (object)array_merge((array)$pad[$key], (array)$value);
  125. }
  126. var_dump($out);
  127. }
Add Comment
Please, Sign In to add comment