1

好的,所以我有一个 $unique_answer_title包含多个数组。以下是我使用时得到的结果var_dump($unique_answer_title)

array(4) { [0]=> string(9) "Immediate" [1]=> string(3) "Yes" [2]=> string(29) "Have a representative call me" [3]=> string(109) "Biomek<sup><em>&#135;&#135;</em></sup> FX<sup>P</sup> Workstation" } array(8) { [0]=> string(9) "Immediate" [1]=> string(3) "Yes" [2]=> string(29) "Have a representative call me" [3]=> string(109) "Biomek<sup><em>&#135;&#135;</em></sup> FX<sup>P</sup> Workstation" [4]=> string(9) "Immediate" [5]=> string(2) "No" [6]=> string(29) "Have a representative call me" [7]=> string(111) "Biomek<sup><em>&#135;&#135;</em></sup> NX<sup>P</sup> Workstation " } array(12) { [0]=> string(9) "Immediate" [1]=> string(3) "Yes" [2]=> string(29) "Have a representative call me" [3]=> string(109) "Biomek<sup><em>&#135;&#135;</em></sup> FX<sup>P</sup> Workstation" [4]=> string(9) "Immediate" [5]=> string(2) "No" [6]=> string(29) "Have a representative call me" [7]=> string(111) "Biomek<sup><em>&#135;&#135;</em></sup> NX<sup>P</sup> Workstation " [8]=> string(20) "Greater than 3 years" [9]=> string(3) "Yes" [10]=> string(42) "Have a representative contact me via email" [11]=> string(109) "Biomek<sup><em>&#135;&#135;</em></sup> FX<sup>P</sup> Workstation" } array(18) { [0]=> string(9) "Immediate" [1]=> string(3) "Yes" [2]=> string(29) "Have a representative call me" [3]=> string(109) "Biomek<sup><em>&#135;&#135;</em></sup> FX<sup>P</sup> Workstation" [4]=> string(9) "Immediate" [5]=> string(2) "No" [6]=> string(29) "Have a representative call me" [7]=> string(111) "Biomek<sup><em>&#135;&#135;</em></sup> NX<sup>P</sup> Workstation " [8]=> string(20) "Greater than 3 years" [9]=> string(3) "Yes" [10]=> string(42) "Have a representative contact me via email" [11]=> string(109) "Biomek<sup><em>&#135;&#135;</em></sup> FX<sup>P</sup> Workstation" [12]=> string(9) "Immediate" [13]=> string(2) "No" [14]=> string(15) "Send literature" [15]=> string(77) "Sign me up for more info on the Biomek 4000<sup>&#134;</sup>." [16]=> string(88) "Biomek<sup><em>&#135;&#135;</em></sup> Assay Workstation" [17]=> string(72) "SPRIworks Library Construction <sup>&#94;&#94;</sup>" } array(22) { [0]=> string(9) "Immediate" [1]=> string(3) "Yes" [2]=> string(29) "Have a representative call me" [3]=> string(109) "Biomek<sup><em>&#135;&#135;</em></sup> FX<sup>P</sup> Workstation" [4]=> string(9) "Immediate" [5]=> string(2) "No" [6]=> string(29) "Have a representative call me" [7]=> string(111) "Biomek<sup><em>&#135;&#135;</em></sup> NX<sup>P</sup> Workstation " [8]=> string(20) "Greater than 3 years" [9]=> string(3) "Yes" [10]=> string(42) "Have a representative contact me via email" [11]=> string(109) "Biomek<sup><em>&#135;&#135;</em></sup> FX<sup>P</sup> Workstation" [12]=> string(9) "Immediate" [13]=> string(2) "No" [14]=> string(15) "Send literature" [15]=> string(77) "Sign me up for more info on the Biomek 4000<sup>&#134;</sup>." [16]=> string(88) "Biomek<sup><em>&#135;&#135;</em></sup> Assay Workstation" [17]=> string(72) "SPRIworks Library Construction <sup>&#94;&#94;</sup>" [18]=> string(9) "Immediate" [19]=> string(2) "No" [20]=> string(30) "Have a representative visit me" [21]=> string(77) "Sign me up for more info on the Biomek 4000<sup>&#134;</sup>." } array(26) { [0]=> string(9) "Immediate" [1]=> string(3) "Yes" [2]=> string(29) "Have a representative call me" [3]=> string(109) "Biomek<sup><em>&#135;&#135;</em></sup> FX<sup>P</sup> Workstation" [4]=> string(9) "Immediate" [5]=> string(2) "No" [6]=> string(29) "Have a representative call me" [7]=> string(111) "Biomek<sup><em>&#135;&#135;</em></sup> NX<sup>P</sup> Workstation " [8]=> string(20) "Greater than 3 years" [9]=> string(3) "Yes" [10]=> string(42) "Have a representative contact me via email" [11]=> string(109) "Biomek<sup><em>&#135;&#135;</em></sup> FX<sup>P</sup> Workstation" [12]=> string(9) "Immediate" [13]=> string(2) "No" [14]=> string(15) "Send literature" [15]=> string(77) "Sign me up for more info on the Biomek 4000<sup>&#134;</sup>." [16]=> string(88) "Biomek<sup><em>&#135;&#135;</em></sup> Assay Workstation" [17]=> string(72) "SPRIworks Library Construction <sup>&#94;&#94;</sup>" [18]=> string(9) "Immediate" [19]=> string(2) "No" [20]=> string(30) "Have a representative visit me" [21]=> string(77) "Sign me up for more info on the Biomek 4000<sup>&#134;</sup>." [22]=> string(9) "Immediate" [23]=> string(2) "No" [24]=> string(5) "Other" [25]=> string(88) "Biomek<sup><em>&#135;&#135;</em></sup> Assay Workstation" }

如何将下面显示的这些数组的所有元素组合成一个数字数组?

array_merge($unique_answer_title)似乎不起作用......并且变量$unique_answer_title本身不是一个数组,它是一组多个数组。如何将所有这些单独数组的元素组合成一个大数组?

4

1 回答 1

1

您需要在 foreach 循环中合并单个数组。

$mergedArray = array();
foreach($unique_answer_title as $single){
  $mergedArray = array_merge($mergedArray, $single);
}
于 2013-05-23T17:42:39.930 回答