我想动态创建一个包含 N 个(不知道 N 个)元素的数组。
类似函数的东西
public function create_array($num_elements){
.....
}
给我一些类似的东西
//call the function....
create_array(3);
//and the output is:
array{
0 => null
1 => null
2 => null
}
我已经想到了array_fill
一个简单的foreach
循环。
还有其他解决方案吗?