可以使用PHP的array_merge()函数将二维数组转化为一维数组。具体操作如下:
$twoDimensionalArray = array(
array('apple', 'banana'),
array('orange', 'grape'),
array('melon', 'watermelon')
);
$oneDimensionalArray = array();
foreach ($twoDimensionalArray as $subArray) {
$oneDimensionalArray = array_merge($oneDimensionalArray, $subArray);
}
print_r($oneDimensionalArray);
输出结果为:
Array
(
[0] => apple
[1] => banana
[2] => orange
[3] => grape
[4] => melon
[5] => watermelon
)