如何合并存储在变量中但不包含在数组本身中的多个单独数组?变量$unique_answer_title
包含这些单独的数组,但是,我试图将它们的所有元素组合成一个大的数字数组..当我使用array_merge($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>‡‡</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>‡‡</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>‡‡</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>‡‡</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>‡‡</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>‡‡</em></sup> FX<sup>P</sup> Workstation"
}
在代码中对您的问题的简短回答是:
$merged = call_user_func_array('array_merge', $unique_answer_title);
这会将您拥有的一个数组转换为多个参数array_merge() http://php.net/array_merge它接受任意数量的参数。
此前(2010 年 9 月)已对此进行了概述:
- 更好的 php array_merge https://stackoverflow.com/questions/3634670/a-better-php-array-merge
如果您随后抱怨双值,这也已经得到处理:
- PHP 合并数组并删除双精度值 https://stackoverflow.com/q/6180090/367456
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)