vendredi 10 février 2017

array + array on each iteration of the while

Vote count: 0

How do I add an array to another? I mean addition, not to add the elements at the end of the array. I have a while structure and I want it to add the values at each iteration.

Tried a few variants like $final_array += $final_array; but I couldn't find a solution and I don't really know how to spell it to find something on SO/Google.

Here is the code:

<?php
$i = 0;
while ($i < 10){
    $i++;
    $sql =  "SELECT * FROM parteneri WHERE nr_intrebare = '$i' AND varianta_raspuns = '$intrebare_01'";
    $result = mysqli_query($con, $sql);

    $final_array = array();

    while ($row = mysqli_fetch_array($result))
    {
        $final_array[] = $row;
    }
}

asked 52 secs ago

Let's block ads! (Why?)



array + array on each iteration of the while

Aucun commentaire:

Enregistrer un commentaire