Php 我真的不知道如何调用数组
我有以下数组:Php 我真的不知道如何调用数组,php,arrays,Php,Arrays,我有以下数组: 1 => array 0 => string '1' 1 => string '2' 2 => array 0 => string '7' 1 => string '8' 我想创建一些对象,在这个例子中是4,第一个的大小乘以第二个的大小 所以我会得到: Object(1,7) Object(1,8) Object(1,7) Object(2,8) Object(1,7,9) Object(1,7,10) Ob
1 => array
0 => string '1'
1 => string '2'
2 => array
0 => string '7'
1 => string '8'
我想创建一些对象,在这个例子中是4,第一个的大小乘以第二个的大小
所以我会得到:
Object(1,7)
Object(1,8)
Object(1,7)
Object(2,8)
Object(1,7,9)
Object(1,7,10)
Object(1,8,9)
Object(1,8,10)
Object(2,7,9)
Object(2,7,10)
Object(2,8,9)
Object(2,8,10)
问题是,我不知道第一个数组的大小,所以可能是这样
1 => array
0 => string '1'
1 => string '2'
2 => array
0 => string '7'
1 => string '8'
3 => array
0 => string '9'
1 => string '10'
所以我会得到:
Object(1,7)
Object(1,8)
Object(1,7)
Object(2,8)
Object(1,7,9)
Object(1,7,10)
Object(1,8,9)
Object(1,8,10)
Object(2,7,9)
Object(2,7,10)
Object(2,8,9)
Object(2,8,10)
它可能更大
对不起,解释得不好,我想不出更好的解释方法了
所以问题是,我将如何去实现这一点?
java中最好是C++,C,C++的解决方案是可以接受的,因为我可以比较容易地转换它们。 你所要寻找的是数组的笛卡尔积。第一步是这样做: 然后必须将数组转换为对象,这不应该是一个挑战