PHP to realize micro-trust and Lucky Red envelopes

Source: Internet
Author: User
 $r) {$rand _money = Number_format ($money _total* $r/$rand _sum, 2); if ($rand _money <= 0.01 | | Number_format (ARRAY_SUM ($ Rand_money_arr), 2) >= Number_format ($money _total, 2)) {$rand _money_arr[$key] = 0.01;} else {$rand _money_arr[$key] = $ Rand_money;}}  $max _index = $max _rand = 0;foreach ($rand _money_arr as $key = $rm) {if ($rm > $max _rand) {$max _rand = $rm; $max _index = $key;}} unset ($rand _money_arr[$max _index]);//Array_sum here ($rand _money_arr) must be less than $money_total $rand_money_arr[$max _index ] = Number_format ($money _total-array_sum ($rand _money_arr), 2) Ksort ($rand _money_arr); return $rand _money_arr;}

The above describes the PHP implementation of the red envelopes, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.