sm21guy
sm21guy

Reputation: 626

combining two arrays , one from array[] another is from array2 = array(); php

im not sure how can i combine these two arrays together:

$query = mysql_query("SELECT * FROM table ORDER BY id");
$rows = array();
while($r = mysql_fetch_assoc($query)) {
   $rows[] = $r;
}

  $out = array("$r,'fruit'=> 'orange','location'=> 'home , 'test'=> 'off'");

As you can see i put all the mysql table data into an array called $rows[] and i have another array called $out

how can i combine this two so i can json encode them with this:

$result_string = json_encode($combined);
print $callback.'('.result_string.');';

Upvotes: 2

Views: 71

Answers (1)

John Woo
John Woo

Reputation: 263693

Use array_merge

 $result = array_merge($rows, $out);

See PHP Manual: array_Merge

Upvotes: 3

Related Questions