【发布时间】:2010-11-28 16:05:45
【问题描述】:
假设我有两个数组
<?PHP
$arr1 = array("a","b","c");
$arr2 = array("1","2","3");
function multiply_arrays($arr1,$arr2){
//what is the best way to do that in terms of speed and memory
return $arr3;
}
?>
将它们相乘的最佳方法是什么?
结果应该是一个具有以下值的数组:
a1 a2 a3 b1 b2 b3 c1 c2 c3
因为我不想面对这样的错误:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 39 bytes)
谢谢
【问题讨论】:
-
在数学上它被称为张量积,但我不记得 OP 所询问的编程术语。
标签: php arrays optimization