Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

40,003 questions

51,950 answers

573 users

How to merge 4 arrays in 1 array in PHP

3 Answers

0 votes
$arr_1 = array("aaa", "bbb");
$arr_2 = array("ccc", "ddd");
$arr_3 = array("eee", "fff");
$arr_4 = array("ggg", "hhh");
$m = array_merge($arr_1, $arr_2, $arr_3, $arr_4);
print_r($m); 
 
/*
run:
  
Array ([0] => aaa [1] => bbb [2] => ccc [3] => ddd [4] => eee [5] => fff [6] => ggg [7] => hhh) 
  
*/

 



answered Feb 6, 2016 by avibootz
0 votes
$arr_1 = array("aaa", "bbb");
$arr_2 = array("ccc", "ddd");
$arr_3 = array("eee", "fff");
$arr_4 = array("ggg", "hhh");
$m = array_merge_recursive($arr_1, $arr_2, $arr_3, $arr_4);
echo "<pre>";
print_r($m); 
echo "</pre>";
 
/*
run:
  
Array
(
    [0] => aaa
    [1] => bbb
    [2] => ccc
    [3] => ddd
    [4] => eee
    [5] => fff
    [6] => ggg
    [7] => hhh
)
  
*/

 



answered Feb 6, 2016 by avibootz
0 votes
$arr_1 = array("aaa", "bbb", 1);
$arr_2 = array("name" => "dan", "profession" => "programmer", 2);
$arr_3 = array("a", "b", "c", "d");
$arr_4 = array(10, 20 , 30);
$m = array_merge($arr_1, $arr_2, $arr_3, $arr_4);
echo "<pre>";
print_r($m); 
echo "</pre>";
 
/*
run:
  
Array
(
    [0] => aaa
    [1] => bbb
    [2] => 1
    [name] => dan
    [profession] => programmer
    [3] => 2
    [4] => a
    [5] => b
    [6] => c
    [7] => d
    [8] => 10
    [9] => 20
    [10] => 30
)
  
*/

 



answered Feb 6, 2016 by avibootz

Related questions

1 answer 131 views
131 views asked Jun 20, 2022 by avibootz
1 answer 193 views
1 answer 166 views
4 answers 362 views
362 views asked Apr 21, 2014 by avibootz
...