I got an error when I did $result1 = implode(' ',$result1)
I use 2 query and wish to combine the result into one, here's my query:
if($stmt->execute()){
$user = $stmt->get_result();
while ($obj = $user->fetch_object()) {
$result1[] = $obj;
}
}
if($stmt->execute()){
$user = $stmt->get_result();
while ($obj = $user->fetch_object()) {
$result2[] = $obj;
}
}
- convert $result1 and result2 to string here
I need $result1 and result2 to be like
'[{
"uId":"1",
"firstName":"James",
"lastName":"Bond"
}]'
so that it can run below code.
$arr1 = json_decode($result1,true);
$arr2 = json_decode($result2,true);
$arr1[0]['task'] = $arr2;
$finalJSON = json_encode($arr1);
echo $finalJSON;
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…