PHP simple full version of WeChat carousel, including front-end and back-end data processing

WBOY
Release: 2016-07-25 08:48:01
Original
1345 people have browsed it
I found that most of what I posted online was incomplete, so I made a contribution and shared it with everyone.

Complete code download: http://yun.baidu.com/s/1i3FXbPr
  1. /**
  2. * $proArr = array('1'=>'Probability', '2'=>'Probability');
  3. * $proCount = array('1'=>'Inventory', '2'=> ;'Inventory');
  4. */
  5. function getRand($proArr, $proCount) {
  6. $result = '';
  7. $proSum = 0;
  8. foreach ($proCount as $key => $val) {
  9. if ($val <= 0) {
  10. continue;
  11. } else {
  12. $proSum = $proSum + $proArr[$key];
  13. }
  14. }
  15. foreach ($proArr as $key => $proCur ) {
  16. if ($proCount[$key] <= 0) {
  17. continue;
  18. } else {
  19. $randNum = mt_rand(1, $proSum);
  20. if ($randNum <= $proCur) {
  21. $ result = $key;
  22. break;
  23. } else {
  24. $proSum -= $proCur;
  25. }
  26. }
  27. }
  28. unset($proArr);
  29. return $result;
  30. }
Copy code


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!