Between 1 and, if $ a = 35, how can I retrieve all the 10 and remainder floors contained in 35 in an array ($ a % 10) and assign them to $ B?

Source: Internet
Author: User
Between 1 and if $ a35 is used, how can we retrieve all the 10 and remainder floors contained in 35 in an array ($ a % 10) assign a value to $ B? between 1-. if $ a = 35, how can I use an array to retrieve all the 10 and remainder floors contained in 35 ($ a % 10) if you assign a value to $ B, the result should be 10, 10, and 5. I am a white guy. I hope you can give me some advice. thank you very much!


Reply to discussion (solution)

What does this mean?
Http://ideone.com/fE3OsH

 10){array_push($b, 10);$a -= 10;}if ($a) {array_push($b, $a);}print_r($b);

$a = 35;$b = array_merge(array_fill(0, intval($a/10), 10), array($a % 10));print_r($b);
Array(    [0] => 10    [1] => 10    [2] => 10    [3] => 5)

Thank you !! Ask another question.
$ A = 35;
$ B = array_merge (array_fill (0, intval ($ a/10), 10), array ($ a % 10 ));
Print_r ($ B );

If $ a is also an Array, for example, $ a = Array (35, 26), how can we use $ c to represent this multi-dimensional Array?

$a = array (35 , 26);$c = array_map(function($a) {  return array_merge(array_fill(0, intval($a/10), 10), array($a % 10));  }, $a);print_r($c);
Array(    [0] => Array        (            [0] => 10            [1] => 10            [2] => 10            [3] => 5        )    [1] => Array        (            [0] => 10            [1] => 10            [2] => 6        ))

Thank you !!!! Perfect solution

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.