Fill a php array with the content of other php arrays -



Fill a php array with the content of other php arrays -

i've been searching while accomplish question, decided inquire here.

my problem.

i've filled 2 arrays content database this:

$query = "select table_1, table_2 questions"; // execute query or trow error $results = mysqli_query($conn, $query) or die(mysql_error()); $resulttablet1= array(); $resulttablet2= array(); while($row = mysqli_fetch_array($results)) { // add together right questions array $resulttablet1[] = $row['table_1']; $resulttablet2[] = $row['table_2']; }

so i've got 2 arrays, each filled content of 1 table. working fine. want set 2 arrays 1 array acts 1 big array. this:

$newarray = array(); $newarray[$resulttablet1, $resulttablet2];

or

$newarray = array($resulttablet1, $resulttablet2);

then want echo $newarray , show elements of other 2 arrays.

i know can echo both arrays separately, not possible goal i'm trying accomplish.

thanks in advance.

edit realise question isn't clear enough, i'll seek explain bit better.

on top of question want show the content of both arrays 1 1 on button click. that's i'm doing @ moment this:

// retrieve value javascript file, add together 1 variable each time button clicked send value server using jquery ajax $value = (int)$_post["question_nmbr"]; // utilize $value echo right element out of array. echo "<li>$resulttablet1[$value]</li>";

everytime button clicked ajax loads php file , value increased next question loaded.

i want same thing array has multiple arrays within of it.

array_merge doesn't trick think, cause print_r($result); gives me content of array.

i hope question little bit more clear now.

i found answer, removed reply already.

array_merge did trick after all, don't know did wrong first time can echo fine.

here how works:

// retrieve value javascript file, add together 1 variable each time button clicked send value server using jquery ajax $value = (int)$_post["question_nmbr"]; $newarray = array_merge($resulttablet1, $resulttablet2); echo "<li>$newarray[$value]</li>";

hope find useful, if not inquire more info :)

php arrays string merge show

Comments

Popular posts from this blog

php - Edges appear in image after resizing -

ios8 - iOS custom keyboard - preserve state between appearances -

Delphi change the assembly code of a running process -