欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

体育彩票排列三组选三算法分享_PHP教程

程序员文章站 2022-05-16 22:49:58
...
复制代码 代码如下:

function arrange($arr){
$new_arr = array();
$c = count($arr);
foreach($arr as $key=>$vo){
$lin = $arr;
array_splice($lin,$key,1);
for($l=0;$l $larr = array();
$larr[] = $lin[$l];
$larr[] = $vo;
$larr[] = $vo;
$new_arr[] = $larr;
}
}
return $new_arr;
}
$arr = array(1,2,3,4);
$r = arrange($arr);
print_r($r);

得到的结果是:

复制代码 代码如下:

Array
(
[0] => Array
(
[0] => 2
[1] => 1
[2] => 1
)

[1] => Array
(
[0] => 3
[1] => 1
[2] => 1
)

[2] => Array
(
[0] => 4
[1] => 1
[2] => 1
)

[3] => Array
(
[0] => 1
[1] => 2
[2] => 2
)

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/736789.htmlTechArticle复制代码 代码如下: function arrange($arr){ $new_arr = array(); $c = count($arr); foreach($arr as $key=$vo){ $lin = $arr; array_splice($lin,$key,1); for($l=0;$l$c-1;$l++){ $...
相关标签: php 体育彩票