1

Ok , so I have a $unique_answer_title contains multiple arrays. Below is what I get when I use var_dump($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>&#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" } array(18) { [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" [12]=> string(9) "Immediate" [13]=> string(2) "No" [14]=> string(15) "Send literature" [15]=> string(77) "Sign me up for more info on the Biomek 4000<sup>&#134;</sup>." [16]=> string(88) "Biomek<sup><em>&#135;&#135;</em></sup> Assay Workstation" [17]=> string(72) "SPRIworks Library Construction <sup>&#94;&#94;</sup>" } array(22) { [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" [12]=> string(9) "Immediate" [13]=> string(2) "No" [14]=> string(15) "Send literature" [15]=> string(77) "Sign me up for more info on the Biomek 4000<sup>&#134;</sup>." [16]=> string(88) "Biomek<sup><em>&#135;&#135;</em></sup> Assay Workstation" [17]=> string(72) "SPRIworks Library Construction <sup>&#94;&#94;</sup>" [18]=> string(9) "Immediate" [19]=> string(2) "No" [20]=> string(30) "Have a representative visit me" [21]=> string(77) "Sign me up for more info on the Biomek 4000<sup>&#134;</sup>." } array(26) { [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" [12]=> string(9) "Immediate" [13]=> string(2) "No" [14]=> string(15) "Send literature" [15]=> string(77) "Sign me up for more info on the Biomek 4000<sup>&#134;</sup>." [16]=> string(88) "Biomek<sup><em>&#135;&#135;</em></sup> Assay Workstation" [17]=> string(72) "SPRIworks Library Construction <sup>&#94;&#94;</sup>" [18]=> string(9) "Immediate" [19]=> string(2) "No" [20]=> string(30) "Have a representative visit me" [21]=> string(77) "Sign me up for more info on the Biomek 4000<sup>&#134;</sup>." [22]=> string(9) "Immediate" [23]=> string(2) "No" [24]=> string(5) "Other" [25]=> string(88) "Biomek<sup><em>&#135;&#135;</em></sup> Assay Workstation" }

How can I combine all the elements of these arrays shown below into one numerical array?

array_merge($unique_answer_title) doesn't seem to work ... and the variable $unique_answer_title itself is not an array, it's a group of multiple arrays. How can I get the elements of all these individual arrays together into one big array?

hakre
  • 193,403
  • 52
  • 435
  • 836
user1787184
  • 83
  • 1
  • 4
  • 11
  • Hmm, this question reminds me some other question, let me see... – hakre Jun 23 '13 at 11:28
  • Oh, here it is: http://stackoverflow.com/questions/16723700/how-can-i-merge-multiple-separate-arrays-that-are-not-included-in-an-array - I now stop downvoting your low quality questions and place close/deletion votes. You seem to like this help-vampire stuff so I directly flag you with the moderators. – hakre Jun 23 '13 at 11:30

1 Answers1

1

You need to merge the single arrays in a foreach loop.

$mergedArray = array();
foreach($unique_answer_title as $single){
  $mergedArray = array_merge($mergedArray, $single);
}
Derek
  • 3,438
  • 1
  • 17
  • 35
  • $unique_answer_title contains many arrays in it , it's not an array itself ... why would you iterate over it ??? – user1787184 May 23 '13 at 17:44
  • It doesnt work .. this is what I am getting Warning: array_merge(): Argument #2 is not an array in C:\xampp\htdocs\tms\_reports\lead_synopsis.php on line 730 – user1787184 May 23 '13 at 17:53
  • Can you add the code where $unique_answer_title is defined? Was that a single var_dump call or the output of var_dump in a loop/multiple calls? – Derek May 23 '13 at 17:55
  • that was a single var_dump ... the arrays that you see in the question is the var_dump from $unique_answer_title – user1787184 May 23 '13 at 17:57
  • Can you var_dump($single)? Maybe add the portion of code where you are dumping this to the original post? – Derek May 23 '13 at 18:01
  • that is what I get tring(9) "Immediate" Warning: array_merge(): Argument #2 is not an array in C:\xampp\htdocs\tms\_reports\lead_synopsis.php on line 730 string(3) "Yes" Warning: array_merge(): Argument #1 is not an array in C:\xampp\htdocs\tms\_reports\lead_synopsis.php on line 730 string(29) "Have a representative call me" – user1787184 May 23 '13 at 18:04