我该如何合并未包括在阵列多个独立的数组? [英] How can I merge multiple separate arrays that are not included in an array?

查看:126
本文介绍了我该如何合并未包括在阵列多个独立的数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何可能合并中存储未包含在阵列本身的可变的多个单独的阵列?变量 $ unique_answer_title 包含这些单独的阵列,但是,我想他们的所有元素组合成一个大的数字阵列..当我使用 array_merge( $ unique_answer_title),没有被退回。下面是包含在变量中的数据。

 阵列(4){
        [0] =>串(9)立即
        [1] =>串(3)是
        [2] =>串(29)有一个重新presentative叫我
        [3] =>串(109)BIOMEK<想喝>< EM>&放大器;#135;&放大器;#135;< / EM>< / SUP> FX<想喝> P< / SUP>工作站
        }    阵列(8){
        [0] =>串(9)立即
        [1] =>串(3)是
        [2] =>串(29)有一个重新presentative叫我
        [3] =>串(109)BIOMEK<想喝>< EM>&放大器;#135;&放大器;#135;< / EM>< / SUP> FX<想喝> P< / SUP>工作站
        [4] =>串(9)立即
        [5] =>串(2)为否
        [6] =>串(29)有一个重新presentative叫我
        [7] =>串(111)BIOMEK<想喝>< EM>&放大器;#135;&放大器;#135;< / EM>< / SUP> NX<想喝> P< / SUP>工作站
        }    阵列(12){
        [0] =>串(9)立即
        [1] =>串(3)是
        [2] =>串(29)有一个重新presentative叫我
        [3] =>串(109)BIOMEK<想喝>< EM>&放大器;#135;&放大器;#135;< / EM>< / SUP> FX<想喝> P< / SUP>工作站
        [4] =>串(9)立即
        [5] =>串(2)为否
        [6] =>串(29)有一个重新presentative叫我
        [7] =>串(111)BIOMEK<想喝>< EM>&放大器;#135;&放大器;#135;< / EM>< / SUP> NX<想喝> P< / SUP>工作站
        [8] =>串(20)大超过3年
        [9] =>串(3)是
        [10] =>串(42)有一个重新presentative通过电子邮件联系我。
        [11] =>串(109)BIOMEK<想喝>< EM>&放大器;#135;&放大器;#135;< / EM>< / SUP> FX<想喝> P< / SUP>工作站
        }


解决方案

简短的回答在code你的问题是:

  $ =合并call_user_func_array('array_merge',$ unique_answer_title);

这是打开一个阵列必须为多个参数 array_merge() 它接受任意数量的参数。

它一直previously(2010年9月)中概述:

如果你再抱怨双重价值,这已经被处理,以及:

How is it possible to merge multiple separate arrays stored in a variable that are not included in an array themselves ? The variable $unique_answer_title contains these separate arrays, however , I am trying to combine all their elements into one big numerical array.. when I use array_merge($unique_answer_title), nothing gets returned. Below is the data contained in the variable ..

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" 
        }

解决方案

The short answer to your question in code is:

$merged = call_user_func_array('array_merge', $unique_answer_title);

This is turning the one array you have into multiple parameters to array_merge() which accepts any number of parameters.

It had been previously (Sep 2010) outlined in:

If you then complain about double values, this has been handled already as well:

这篇关于我该如何合并未包括在阵列多个独立的数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆