-2
Array ( [0] => tirupur ) 
Array ( [0] => coimbatore ) 
Array ( [0] => coimbatore [1] => chennai ) 
Array ( [0] => coimbatore [1] => chennai [2] => madurai ) 
Array ( [0] => bangalore ) 

I want the final array to be like below output

Array ( [0] => tirupur [1]=>coimbatore [2]=>chennai [3]=>madurai [4]=>bangalore)
Prix
  • 19,417
  • 15
  • 73
  • 132
Arun sankar
  • 94
  • 1
  • 2
  • 17

2 Answers2

0

you can combine first all array in to one array and then try to do like this way

<?php
$array1 = array("orange", "apple", "grape");
$array2 = array("peach", 88, "plumb");
$array3 = array("lemon", 342);
$newArray = array_merge($array1, $array2, $array3);

array_unique($newArray);

hope this will sure help you

liyakat
  • 11,825
  • 2
  • 40
  • 46
  • $functional_results = $objMain->getResults("SELECT DISTINCT locations FROM tbl_jobs"); foreach($functional_results as $res){ $loc=explode("-",$res['locations']); print_r($loc); echo '
    '; } my array list are only in one array.. not different array list.. how can merge
    – Arun sankar Jul 31 '13 at 06:43
  • @user853278 I have mention in my answer that use the `array_unique` function if you have one array. – Code Lღver Jul 31 '13 at 06:45
0

As a solution to your problem please try executing the following code snippet

  $a=array('tirupur');
  $b=array('coimbatore');
  $c=array('coimbatore','chennai');
  $d=array('coimbatore','chennai','madurai');
  $e=array('bangalore');
  $x=array_unique(array_merge($a,$b,$c,$d,$e));
  $result=array_values($x);
  print_r($result);
 ?>
Rubin Porwal
  • 3,736
  • 1
  • 23
  • 26