How to join 2 Json in 1

0

Hi, I have a php file that generates this:

["1", "Raul", "Martinez", "Perez", "8.2", "0", "masculine", "34", "spring 21"]

["65", "My Current Location", "5 Naucalpan Street", "19.4694766998291", "-99.23297119140625", "19.4689194", "- 99.2242569", "30.93", "1", "3", "Pending"]

and I'd like to get this:

["1", "Raul", "Martinez", "Perez", "8.2", "0", "masculine", "34", "spring 21", "65", "My Current Location" , "Calle 5 Naucalpan", "19.4694766998291", "-99.23297119140625", "19.4689194", "- 99.2242569", "30.93", "1", "3", "Pending"]

I can not find anything that works for me, this is my code:

if($resultset= getSQLResultSet("SELECT * FROM 'Operador' WHERE id_operador='$id' LIMIT 1"))
{
    while($row=$resultset->fetch_array(MYSQLI_NUM))
    {
        echo json_encode($row);
    }
}
if($resultset2= getSQLResultSet("SELECT * FROM 'Viajes_Pendientes' WHERE status='$status' LIMIT 1"))
{
    while($row2=$resultset2->fetch_array(MYSQLI_NUM))
    {
        echo json_encode($row2);
    }
}
    
asked by karasu55 10.10.2017 в 20:57
source

1 answer

1

and what if you try to do the following:

$array1 = array();
$array2 = array();

if($resultset= getSQLResultSet("SELECT * FROM 'Operador' WHERE id_operador='$id' LIMIT 1"))
{
    while($row=$resultset->fetch_array(MYSQLI_NUM))
    {
        $array1 = $row;
    }
}
if($resultset2= getSQLResultSet("SELECT * FROM 'Viajes_Pendientes' WHERE status='$status' LIMIT 1"))
{
    while($row2=$resultset2->fetch_array(MYSQLI_NUM))
    {
        $array2 = $row2;
    }
}

$resultado = array_merge($array1, $array2);

echo json_encode($resultado);

I hope you serve, greetings!

    
answered by 10.10.2017 / 21:25
source