时间:2021-07-01 10:21:17 帮助过:36人阅读
这个意思?
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)
非常感谢!!麻烦再继续问个问题
$a = 35;
$b = array_merge(array_fill(0, intval($a/10), 10), array($a % 10));
print_r($b);
如果$a也是个数组,例如 $a =Array (35 , 26) ,要怎么把这个多维数组用$c表示出来呢
$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 ))
谢谢,谢谢,感激涕零!!!!完美解决