2

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.');';
1
  • have you gone through array_merge function? Commented Oct 5, 2012 at 7:55

1 Answer 1

3

Use array_merge

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

See PHP Manual: array_Merge

Sign up to request clarification or add additional context in comments.

1 Comment

oh theres an merge function for array , thanks for pointing out!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.