Home > php教程 > php手册 > body text

数组组合问题

WBOY
Release: 2016-06-06 20:11:21
Original
911 people have browsed it

array(array(1,2,3),array(4,5)) php?怎么写?把里面的数值组合起来得到结果是 array(array(1,4),array(1,5),array(2,4),array(2,5),array(3,4),array(3,5)) 答: $a = array(array(1,2,3),array(4,5));list($va,$vb) = $a;foreach($va as $k=$v){foreach($vb

array(array(1,2,3),array(4,5))
php?怎么写?把里面的数值组合起来得到结果是
array(array(1,4),array(1,5),array(2,4),array(2,5),array(3,4),array(3,5))

答:

$a = array(array(1,2,3),array(4,5));
list($va,$vb) = $a;
foreach($va as $k=>$v){
	foreach($vb as $key=>$val){
		$r[] = array($v,$val);
	}
}
var_dump($r);
Copy after login
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template