PHP combine two array

PHP将两个数组

Tags: php
标签: php

问题 (Question)

i have one array such as any $_POST without key,after clear html tags i want to merge and combine with other array.for example

PHP

$farray= array($a , $b , $c);

i want to merge with below array:

PHP

$filter=array('id'=>$farray[0], 
              'description'=>$farray[1], 
              'portal'=>$farray[2]);

those array are sample like my code, how to merge this arrays, i dont want to use array cell

我有一个阵列等任何$_POST没有钥匙,在清晰的HTML标签我想融合,结合其他array.for例子

PHP

$farray= array($a , $b , $c);

我想用下面的数组合并:

PHP

$filter=array('id'=>$farray[0], 
              'description'=>$farray[1], 
              'portal'=>$farray[2]);

这些阵列的样品,喜欢我的代码,如何将这个数组,我想使用阵列单元

最佳答案 (Best Answer)

 $filter = array_combine(array("id","description", "portal"), $farray);
 $filter = array_combine(array("id","description", "portal"), $farray);

答案 (Answer) 2

Not sure what you're wanting, but there's array_merge

不知道你想要的,但有array_merge

答案 (Answer) 3

    <?php
$a1=array("a"=>"Horse","b"=>"Dog");
$a2=array("c"=>"Cow","d"=>"Cat");
print_r(array_merge($a1,$a2));
?> 

output will be Array ( [a] => Horse [b] => Dog [c] => Cow [d]=>Cat)

    <?php
$a1=array("a"=>"Horse","b"=>"Dog");
$a2=array("c"=>"Cow","d"=>"Cat");
print_r(array_merge($a1,$a2));
?> 

Horse [b] => Dog [c] => Cow [d]=>Cat)">输出将阵列([一] =>马[B] =>狗[ C ] =>牛[D] =>猫)

本文翻译自StackoverFlow,英语好的童鞋可直接参考原文:http://stackoverflow.com/questions/16925964